Created
March 24, 2017 15:36
-
-
Save UCh/5a72f16d627212e7a1dd62f0f74c2257 to your computer and use it in GitHub Desktop.
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
[MenuItem("Edit/Search missing references in prefabs (Full project)", false, 50)] | |
public static void FindMissingReferencesInProject() | |
{ | |
UnityEngine.Debug.Log("Starting search for missing components in project prefabs"); | |
var paths = AssetDatabase.FindAssets("t:prefab").ToList().Select(guid => AssetDatabase.GUIDToAssetPath(guid)); | |
foreach (var path in paths) | |
{ | |
var go = AssetDatabase.LoadAssetAtPath<GameObject>(path); | |
var components = go.GetComponents<Component>(); | |
var componentsChilds = go.GetComponentsInChildren<Component>(); | |
int array1OriginalLength = components.Length; | |
Array.Resize<Component>(ref components, array1OriginalLength + componentsChilds.Length); | |
Array.Copy(componentsChilds, 0, components, array1OriginalLength, componentsChilds.Length); | |
foreach (var component in components) | |
{ | |
if (component == null) | |
{ | |
UnityEngine.Debug.LogError("MISSING COMPONENT: " + path); | |
break; | |
} | |
} | |
} | |
UnityEngine.Debug.Log("Search completed"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This editor script for Unity locates all prefabs in the project that has a missing reference and output the path in the console