using UnityEditor; using UnityEngine; public class TestEditor : Editor { /// /// ÐÐÊý /// public static int rowCount; /// /// ÁÐÊý /// public static int colCount; [MenuItem("Custom/Fun")] public static void Fun() { Transform[] trans = Selection.transforms; for (int i = 0; i < trans.Length; i++) { for (int j = 0; j < trans[i].GetComponentsInChildren().Length; j++) { for (int k = 0; k < trans[i].GetComponentsInChildren()[j].sharedMaterials.Length; k++) { string path = trans[i].GetComponentsInChildren()[j].sharedMaterials[k].name; Debug.Log(trans[i].GetComponentsInChildren()[j].name + " : " + path + " : " + k); trans[i].GetComponentsInChildren()[j].sharedMaterials[k] = Resources.Load("Materials/" + path); } } } } }