Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [MenuItem("Tools/Find and Remove missing scripts In Selection")]
- public static void RemoveMissingScripts()
- {
- foreach (var go in Selection.gameObjects)
- {
- var amount = RemoveMissingScripts(go);
- if (amount > 0)
- {
- Debug.LogFormat($"Removed {amount} missing script(s) in {go.name}");
- }
- }
- }
- private static int RemoveMissingScripts(GameObject go)
- {
- int amount = GameObjectUtility.RemoveMonoBehavioursWithMissingScript(go);
- for (int i = 0; i < go.transform.childCount; i++)
- {
- var child = go.transform.GetChild(i).gameObject;
- amount += RemoveMissingScripts(child);
- }
- return amount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement