subscribe via rss
8 Mar 2010

[Unify Wiki] FindMissingScripts

Author: Unity3D News Pipe | Filed under: Technology

Summary: New page: Author: SimTex with slight tweaks by Clement == Description == Allows you to add a search a project for all instances of missing mono script. == Usage == In the editor, a script that ha...


Author: SimTex with slight tweaks by Clement

== Description ==

Allows you to add a search a project for all instances of missing mono script.

== Usage ==
In the editor, a script that has been assigned to an object, but subsequently deleted has the string "Missing (Mono Script)" where the script class/filename should be.

It is possible to search a project to find all missing scripts using this editor script. To use it, save the file as "assets/editor/FindMissingScripts.cs". Not that it is important to save it into the editor directory.

Next for each level in your unity project, run the script. It's located under the window menu.

== C# - FindMissingScripts.cs ==

<csharp>

using UnityEngine;
using UnityEditor;
public class FindMissingScripts : EditorWindow {

[MenuItem("Window/FindMissingScripts")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(FindMissingScripts));
}

public void OnGUI()
{
if (GUI.Button(new Rect(0.0f, 60.0f, 100.0f, 20.0f), "Find Missing Scripts"))
{
GameObject[] go = Selection.gameObjects;
foreach (GameObject g in go)
{

Component[] components = g.GetComponents<Component>();
for (int i = 0; i < components.Length; i++)
{
if (components[i] == null)
{
Debug.Log(g.name + " has an empty script attached in position: " + i);
}
}
}
}
}
}

</csharp>

[[Category:Editor Scripts]]
[[Category:C Sharp]]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>