• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AR_Rizvi · Sep 12, 2013 at 02:17 PM · editor-scriptingtexture2dchecking

how to checking If texture is in use in hierarchy

Hi guys i am writing a editor script for discarding unused textures from the project folder Or save unused textures to another folder

so My question is that is their a way to check that a particular texture is in use in with objects in hierarchy

i hope i made my self clear

so far i achieve this wid my code newbie coding skills

 using UnityEngine;
 using System.Collections;
 using System.IO;
 using UnityEditor;
 using System.Collections.Generic;
 
 
 
 
 public class Texture_finder : EditorWindow {
     
         List<Texture2D> textureList = new List<Texture2D>();
     
      [MenuItem("Window/Texture Test")]    
     
     
     
     public static void ShowWindow()
     {
         EditorWindow.GetWindow(typeof(Texture_finder));
         
     }
 
     
     void OnInspectorUpdate() {
        
         Repaint();
     }
     
     
     
     //-----------------------------------------------------------
     Texture2D[] AllTexture;
     Object mObject;
     string path;
     string extention = "meta";
      GameObject[] gameObjs ;
     string TextureName ;
     object[] allObjects;
      
     
     
     void Start()
     {
          
          
     }
 
     
     void OnGUI()
     {
 //****************************************************************
         GUILayout.BeginHorizontal ("box");
         GUILayout.Label("Texture Finder");
         if (GUILayout.Button("Find Texture "))
         {
             Find_text();
         }
          GUILayout.EndHorizontal ();
         
         
         GUILayout.BeginHorizontal ("box");
           mObject = EditorGUILayout.ObjectField( " drop Texture:", mObject, typeof(Texture2D), true ); 
          
     
         GUILayout.EndHorizontal ();
 //****************************************************************
     }
     
     void Find_text()
     {
         allObjects = FindObjectsOfTypeAll(typeof(GameObject)) ;
 //    Debug.Log(allObjects.Length);
         
         
         
         path = "Assets/Textures";
             
         DirectoryInfo dir = new DirectoryInfo(path);
         FileInfo[] info=dir.GetFiles("*.*");
         
         for(int i=0; i<info.Length;i++)
         {
             if(!info[i].Name.Contains(".meta") )
             {
                   foreach(GameObject Obj in allObjects)
                 {   Debug.Log (Obj);
                     if(Obj.renderer)
                     {
                     TextureName = Obj.renderer.sharedMaterial.mainTexture.name;
 Debug.Log (TextureName);
                        
                         
                         if( TextureName == info[i].Name)    
                           {
                         Debug.Log (info[i].Name);
                         }
                     }
                 }
             }
         }
         
         foreach(FileInfo f in info)
         {
 //            Debug.Log(f.Name);
         }
             
     }
 }
 

Any help would be appreciated Thanks AR

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AR_Rizvi · Sep 13, 2013 at 01:44 PM

http://forum.unity3d.com/threads/132008-Resource-Checker-%28FREE%29-List-Texture-Material-Mesh-Memory-use-in-scenend

found the solution off all my problem thanks to me of course thanks

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image perchik · Sep 13, 2013 at 01:46 PM 0
Share

this is why you should search the forum before you post a question. Do your homework before expecting us to solve your problems.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Swap GUI Texture with button press in C# 1 Answer

Apply Image Effect to Image 1 Answer

Modify sprite geometry using AssetPostprocessor 0 Answers

Saving texture of selected GO (Editor Script) 2 Answers

Editor class "Texture Importer" question (applying settings to multiple texture assets). 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges