Created
November 5, 2024 23:19
-
-
Save andydbc/aa205421fb24490d63d31cd483694b86 to your computer and use it in GitHub Desktop.
Helper tool to identify missing component scripts on Prefabs in the project.
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 System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEngine; | |
using UnityEditor; | |
public static class EditorUtils | |
{ | |
static void FindMissingScriptsInGO(GameObject go) | |
{ | |
var components = go.GetComponents<Component>(); | |
foreach(var component in components) | |
{ | |
if(component == null) | |
{ | |
Debug.Log("Missing script found in: " + go.name); | |
} | |
} | |
foreach(Transform child in go.transform) | |
{ | |
FindMissingScriptsInGO(child.gameObject); | |
} | |
} | |
[MenuItem("Tools/Find Missing Scripts")] | |
static void FindMissingScripts() | |
{ | |
string[] prefabs = AssetDatabase.FindAssets("t:Prefab").ToArray(); | |
foreach(var prefab in prefabs) | |
{ | |
string path = AssetDatabase.GUIDToAssetPath(prefab); | |
GameObject obj = AssetDatabase.LoadAssetAtPath<GameObject>(path); | |
FindMissingScriptsInGO(obj); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment