- Home /
The referenced script on this Behaviour is missing!
So I have 3 scenes. Setup, Level1, and Shared. Setup and Level1 run an additive load for the Shared level on start - loading in common components.
When they do so I get a grip of 'The referenced script on this Behaviour is missing!' errors. On inspection no GameObject is identified and it points to MonoBehaviour.cpp line 1509. To make matters worse, when I run Shared on its own, I dont see this error.
Any suggestion on how I could debug this ?
I created a new project, copied over all my assets.
The error has gone away. There must be a bug In the library files.
There error would be in a scene file, did you copy those as well?
Yes I did copy the scene files.
I see where your getting at (comments on answer). But I think I might have a bug from down in unitys guts.
$$anonymous$$y main concern right now is replicating the bug in a project that is south of 500mb.
Even though it's a question from a long time ago, a while ago I made a plugin for this, "$$anonymous$$issing Script Hero": http://forum.unity3d.com/threads/released-missingscripthero-finding-missing-script-references-the-easy-way.273925/
Answer by whydoidoit · Jul 10, 2012 at 07:39 PM
You can find missing scripts using this.
Cool script.
Searched 170 GameObjects, 608 components, found 0 missing UnityEngine.Debug:Log(Object) Find$$anonymous$$issingScripts:FindInSelected() (at Assets/Unity Commons/Editor/Find$$anonymous$$issingScripts.cs:38) Find$$anonymous$$issingScripts:OnGUI() (at Assets/Unity Commons/Editor/Find$$anonymous$$issingScripts.cs:16) UnityEditor.DockArea:OnGUI()
Damn! Probably need to use @Bunny83's suggestion and try the prefabs.
Hmm, if the script works, it should also work on prefabs. I'm not sure if Selection.gameObjects only returns the toplevel selection, or all childs as well, anyway i guess it's better to do a manual recursive depth search. $$anonymous$$eep in $$anonymous$$d that GetComponentsInChildren doesn't work on prefabs since it only returns active gameobjects and prefabs aren't active unless you instantiate them ;)
very useful script.. especially Find$$anonymous$$issingScriptsRecursively version ..also prefabs can be scanned.
Answer by Linus · Apr 18, 2013 at 09:50 PM
Right clicking the assets folder and selecting "Reimport All" solved it for me.
I had tried the script whydoidoit suggested, but nothing was found. I had also tried every prefab in a new scene, and looking at each object in the scene.
Unity 4.1.2
Answer by Bovine · Jul 10, 2012 at 07:25 PM
Load each scene and click on the console line that's telling you that you have a missing script - the GameObject in question might not be in the scene you're editing.
1) If I load Level1 or Setup without loading Shared (additivly) I do not get the error.
2) If I load shared by it self i do not get the error
3) If I load Shared additivly I get the error.
When I get the error no GameObject is identified, only $$anonymous$$onoBehaviour.cpp line 1509.
I'm suggesting that having run your game in the editor, you stop the game and then in the editor load the scene for each of the levels concerned and click the console output.
Whenever I delete\lose a script and get this error, this is how I find the offending GameObjects.
Your 1, 2, 3 above suggests something else might be going on however...
I just tried this by attaching a script to a GO and then deleting it and I see the same mono line that you do, however, provided I have, in the Unity editor, the scene loaded with the GameObject in it that has the missing script, when I click the Console line telling me about it, the offending item is highlighted for me in the hierarchy.
The error only appears on play.
1) If I load Level1 or Setup without loading Shared (additivly) I do not get the error.
2) If I load shared by it self i do not get the error
3) If I load Shared additivly I get the error.
4) The error does not exist when not playing.
When I get the error no GameObject is identified, only $$anonymous$$onoBehaviour.cpp line 1509.
Simply put, I think I have a bug.
It could also be on a prefab that is instantiated at runtime. So just check all assets. Create an empty scene and drag all prefabs you have into that scene and check them for missing $$anonymous$$onoBehaviours.
Generally try to avoid deleting script files and if you do, make sure they aren't used anywhere in the project. Once the script has been deleted, there's no way to deter$$anonymous$$e the name of that script or to automatically find such a broken link.
Answer by Aftech · Dec 12, 2013 at 01:45 PM
I had a similar issue with Unity 4.3.1f1 and finally just got rid of the warnings; I'm not entirely sure it was the same issue as nventimiglia, my case seems easier with a single scene. ( no additive loading or anything like that ). But I thought I'd share since I did use all suggestions on this thread:
In my case, after deleting old scripts, the issue was that the prefab instance was updated to not use the MonoBehavior component, but the prefab in the asset folder still had those empty MonoBehavior components. ( which is something the FindMissingScriptsRecursively script couldn't detect -- since the prefab INSTANCE was fixed/up to date )
after 45min trying to figure out where those warnings were coming from, the fix was painfully easy and obvious: press APPLY on the prefab instance to update the prefab in the assets too!
with the prefab and it's instance updated, the warnings disapeared.
I won't be forgetting the apply button anytime soon :)
Answer by YondernautsGames · Feb 21, 2016 at 12:52 PM
Just as an additional note, there is an issue with file naming here. If your behavior class name is different to the file name, it can still show up on the object in the editor without the "Missing (Mono Script)", but will still throw that missing behavior warning and I believe the component will not run. This is particularly insidious with case sensitivity, as Windows does not consider a change of case as renaming a file, so will just switch back to the original case.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
A node in a childnode? 1 Answer
Saving final score and displaying on main menu 1 Answer
null texture passed to GUI.DrawTexture 0 Answers
Get Set Errors C# 2 Answers