Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by lowbloodsugar · Mar 03, 2010 at 04:12 AM · editoreditor-scriptingmissing

Searching a project for "Missing (Mono Script)"

I am getting ready to launch a new game and am going over it with a fine toothed comb to make sure everything is correct.

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. Is it possible to search a project to find all missing scripts?

I have tried using GetComponents, but do not know what I should put into the type field. I have also tried using GetComponent with a null string, "Missing, and "Missing (Mono Script)" as the parameter, but that always returns null. Since I do not know the name of the missing scripts, it makes the problem more difficult.

Is there any other approaches to try, other than hiring an intern?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Yorick · Mar 03, 2010 at 03:09 PM 0
Share

I don't think there is way to search for that... Can I give points for the intern joke? :-)

5 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by SimTex · Mar 07, 2010 at 09:45 PM

Can be done with some editor scripting:

You need to search all game objects for empty (null) components. This can e.g. be done like this:

Select all objects you want to search for missing scripts and click.

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);
             }
         }

     }
  }

} }

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lowbloodsugar · Mar 08, 2010 at 08:40 PM 0
Share

I reposted this into the wiki:

http://www.unifycommunity.com/wiki/index.php?title=Find$$anonymous$$issingScripts

avatar image Lipis · Mar 09, 2010 at 05:01 AM 0
Share

@Clement if you agree with this answer you should also accept it as the correct one.

avatar image
1

Answer by lowbloodsugar · Mar 08, 2010 at 08:15 PM

That works great! Here are the small changes I had to make to get it to work on my machine (Added using directive and changed MenuItem entry to have window prefix). Save the script as "FindMissingScripts.js"

Clement

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);
         }
     }

 }

} }}

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lipis · Mar 09, 2010 at 05:03 AM 0
Share

@Clement, please don't repost the same answers small changes can be done on the original answer if you simply ask via comment.

avatar image wenhua · Jan 13, 2012 at 01:30 AM 0
Share

then what are we going to do with this script,put where i mean? need to attach to any or do what,as cannot attach to $$anonymous$$issing ($$anonymous$$ono Script)"

avatar image wenhua · Jan 13, 2012 at 01:44 AM 0
Share

where does position:5 means?????

avatar image wenhua · Jan 13, 2012 at 01:54 AM 0
Share

i think $$anonymous$$issing ($$anonymous$$ono Script)" is not in none of those script,So how any solution?

avatar image
1

Answer by daniel254973 · Jan 17, 2019 at 04:57 PM

Due this question still is the first on google looking for missing component's search I have improved it. It looks for missing components on every GameObject and child GameObject of selected. Click Console messages to auto-select GameObject with missing component.

 using UnityEngine;
 using UnityEditor;
 
 public class FindMissingScripts : EditorWindow
 {
     [MenuItem("Tools/FindMissingScripts")]
     public static void ShowWindow()
     {
         GetWindow(typeof(FindMissingScripts)).minSize = new Vector2(190f,60f);
         GetWindow(typeof(FindMissingScripts)).maxSize = new Vector2(190f,60f);
     }
     public void OnGUI()
     {
         if (GUI.Button(new Rect(20.0f, 20.0f, 150.0f, 20.0f), "Find Missing Scripts"))
         {
             Transform[] ts = Selection.GetTransforms(SelectionMode.Deep);
 
             foreach (Transform t in ts)
             {
                 Component[] components = t.GetComponents<Component>();
                 for (int i = 0; i < components.Length; i++)
                 {
                     if (components[i] == null)
                     {
                         Debug.Log(t.name + " has an empty script attached in position: " + i, t.gameObject);
                     }
                 }
             }
         }
     }
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by oliver_unity892 · Mar 27, 2020 at 09:14 AM

Thanks for the code

I'd like to use this to find objects with missing scripts and, ideally, find some info about what the scripts were/are. However I don't know where to save the code to make it function.

I have a load of versions of a given prefab which are showing missing scripts, no idea why as all the scripts appear to be there, guess something went screwy with Collaboration.

Any advice you can provide would be appreciated.

Thanks

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RickshawDerpyDerp · Dec 25, 2020 at 02:44 AM 0
Share

He said to save it in the folder Assets/Editor, which should be in your project by default. You select it from the "Window" dropdown in the Unity Editor.

avatar image
0

Answer by RickshawDerpyDerp · Dec 25, 2020 at 02:44 AM

I thought somebody had a solution to recover the name of the missing script?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I Remove null components ( i.e. "Missing(Mono Script)" ) via editor script? 17 Answers

Track passing time in EditorScript 1 Answer

in-editor cloning of game objects 1 Answer

Size of the header of the EditorWindow 1 Answer

Stop a MonoBehavior from being addable as a script? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges