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 textureList = new List();
[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
↧