首页 > 编程语言 > 详细

Unity之如何移除prefab的missing component

时间:2022-05-27 20:36:16      阅读:12      评论:0      收藏:0      [点我收藏+]

代码如下:

 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

 

Unity之如何移除prefab的missing component

原文:https://www.cnblogs.com/jietian331/p/15352481.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!