Last active
September 8, 2022 09:23
-
-
Save ertanturan/31870a52788260ca910c4d7d228baaf9 to your computer and use it in GitHub Desktop.
Find the missinc scripts in scene
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public class FindMissingScriptsRecursively | |
{ | |
private static void FindInGameObject(GameObject g) | |
{ | |
Component[] components = g.GetComponents<Component>(); | |
for (int i = 0; i < components.Length; i++) | |
{ | |
if (components[i] == null) | |
{ | |
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 + " " ); | |
FindInGameObject(childT.gameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment