Skip to content

Instantly share code, notes, and snippets.

@ertanturan
Last active September 8, 2022 09:23
Show Gist options
  • Save ertanturan/31870a52788260ca910c4d7d228baaf9 to your computer and use it in GitHub Desktop.
Save ertanturan/31870a52788260ca910c4d7d228baaf9 to your computer and use it in GitHub Desktop.
Find the missinc scripts in scene
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