Unity之如何移除prefab的missing component

代码如下:

 1     [MenuItem("FashionBeat/Common/Remove missing component")]
 2     static void RemoveMissing()
 3     {
 4         for (int i = 0; i < Selection.objects.Length; i++)
 5         {
 6             GameObject go = Selection.objects[i] as GameObject;
 7             if (go)
 8             {
 9                 RemoveMissingRec(go);
10                 UnityEngine.Debug.Log("Remove missing com done: " + go.name);
11             }
12         }
13     }
14 
15     static void RemoveMissingRec(GameObject go)
16     {
17         if (!go)
18             return;
19 
20         GameObjectUtility.RemoveMonoBehavioursWithMissingScript(go);
21         foreach (Transform c in go.transform)
22             RemoveMissingRec(c.gameObject);
23     }

 

转载请注明出处:https://www.cnblogs.com/jietian331/p/15352481.html

 

posted @ 2021-09-29 13:38  孤独の巡礼  阅读(520)  评论(0编辑  收藏  举报