···11+using UnityEngine;
22+using UnityEditor;
33+44+public class FindMissingScripts : EditorWindow
55+{
66+ static int go_count = 0, components_count = 0, missing_count = 0;
77+88+ [MenuItem("Window/FindMissingScriptsRecursively")]
99+ public static void ShowWindow()
1010+ {
1111+ EditorWindow.GetWindow(typeof(FindMissingScripts));
1212+ }
1313+1414+ public void OnGUI()
1515+ {
1616+ if (GUILayout.Button("Find Missing Scripts in selected GameObjects"))
1717+ {
1818+ FindInSelected();
1919+ }
2020+ }
2121+ private static void FindInSelected()
2222+ {
2323+ GameObject[] go = Selection.gameObjects;
2424+ go_count = 0;
2525+ components_count = 0;
2626+ missing_count = 0;
2727+ foreach (GameObject g in go)
2828+ {
2929+ FindInGO(g);
3030+ }
3131+ Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count));
3232+ }
3333+3434+ private static void FindInGO(GameObject g)
3535+ {
3636+ go_count++;
3737+ Component[] components = g.GetComponents<Component>();
3838+ for (int i = 0; i < components.Length; i++)
3939+ {
4040+ components_count++;
4141+ if (components[i] == null)
4242+ {
4343+ missing_count++;
4444+ string s = g.name;
4545+ Transform t = g.transform;
4646+ while (t.parent != null)
4747+ {
4848+ s = t.parent.name +"/"+s;
4949+ t = t.parent;
5050+ }
5151+ Debug.Log (s + " has an empty script attached in position: " + i, g);
5252+ }
5353+ }
5454+ // Now recurse through each child GO (if there are any):
5555+ foreach (Transform childT in g.transform)
5656+ {
5757+ //Debug.Log("Searching " + childT.name + " " );
5858+ FindInGO(childT.gameObject);
5959+ }
6060+ }
6161+}
-15
Assets/EnableController.cs
···11-using UnityEngine;
22-using System.Collections;
33-44-public class EnableController : MonoBehaviour {
55-66- // Use this for initialization
77- void Start () {
88-99- }
1010-1111- // Update is called once per frame
1212- void Update () {
1313-1414- }
1515-}