- 之前升级unity 弄丢了一部分文件 当时也没注意 就是一直报错
UnityEngine.UI.Graphic.OnRebuildRequested errors
- 我这个强迫症患者受不了了 找打了这个脚本 很好用 分享出来
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
// from: http://wiki.unity3d.com/index.php?title=FindMissingScripts
public class FindMissingScriptsRecursively : EditorWindow
{
static int go_count = 0, components_count = 0, missing_count = 0;
[MenuItem("Window/Find Missing Scripts (All)")]
static void FindInAll()
{
go_count = 0;
components_count = 0;
missing_count = 0;
foreach (var root in SceneRoots())
{
//Debug.Log(root);
FindInGO(root);
}
Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count));
}
static void FindInGO(GameObject g)
{
go_count++;
Component[] components = g.GetComponents<Component>();
for (int i = 0; i < components.Length; i++)
{
components_count++;
if (components[i] == null)
{
missing_count++;
string s = g.name;
Transform t = g.transform;
while (t.parent != null)
{
s = t.parent.name +"/"+s;
t = t.parent;
}
Debug.Log (s + " has an empty script attached in position: " + i, g);
}
}
// Now recurse through each child GO (if there are any):
foreach (Transform childT in g.transform)
{
//Debug.Log("Searching " + childT.name + " " );
FindInGO(childT.gameObject);
}
}
static IEnumerable<GameObject> SceneRoots()
{
var prop = new HierarchyProperty(HierarchyType.GameObjects);
var expanded = new int[0];
while (prop.Next(expanded)) {
yield return prop.pptrValue as GameObject;
}
}
}
posted @
2016-07-17 13:28
rexzhao
阅读(
314)
评论()
编辑
收藏
举报