The referenced script on this Behaviour is missing!

Hi,

I am getting a warning for this line but I dont reference a script and the thing works?

The referenced script on this Behaviour is missing!
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)

Instantiate( cubePrefab, new Vector3(-1, 1, z), Quaternion.identity);

You can use this to find your missing reference :

http://wiki.unity3d.com/index.php?title=FindMissingScripts

I can quote this :

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 MonoBehaviours.

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 determine the name of that script or to automatically find such a broken link.

From this Unity answer with the same problem than you :

If you click on the warning it will take you to the asset that is having the missing script, one you are there locate the missing script and just remove the component (click on the circle thingy on the right hand side and select remove component)

I had the same problem and the find missing scripts tool linked above reported there was missing scripts but they were not showing up on the objects like freaker said. What I did to fix it was to:

  1. If it was a prefab (revert prefab) that shoulwed the missing scripts and I could remove or fix them.

  2. If it was not a prefab, then make it a prefab and then the missing scripts appeared and could remove or fix them.

After doing some project work on my laptop and sync with my desktop using subversion I had this problem.Even using the editor scripts that are online I could’t find the missing references. The scripts where complaining about missing scripts on objects that had no missing scripts… so I thought… maybe there is something in the object files that is not being shown on the unity editor.

So I went to the source of the objects in the project. This is scary stuff…

I used the sublime text editor for this. I started editing the prefabs. Opened the prefab files and went through all the MonoBehaviour definition. I got each GUID and did a search in the scripts with a “File search” to find if there was any script with that GUID. For every script missing I just deleted the entry. From “MonoBehaviour:” to “-- !u!XXX &XXXXXXX”.

After doing this on all the prefabs that were having problems I ended with a fully working project with no warning.

I only recommend to do this as a last resort… it worked for me… but it might not work for you…

Here are the scripts that worked for me.
[1] Found out the object which was having missing referenced issue by clicking on the warning from the console.
[2] Select that object go to inspector and you’ll see a component with name “Script”.
[3] Delete that component and everything should work.

In my case, I have inadvertently renamed my Script file name. However, the class name inside the script had the old name. I fixed the error by changing the class name inside the script file to match the Script file name. Hope it helps.

had this before recently. Its not the script itself but a pre-fab object. It occurs most often when trying to drag a prefab directly from another scene instead of placing a new copy of the prefab in a new scene. Otherwise if it was a script error if you clicked it, it would open in the monodev string that its having an argument with.

In other words there is something wrong with the object, not the script.

The referenced script on this Behaviour is missing!

I have to admit this is kind of stupid. first I made a project from a tutorial and had the script working fine. then I made another project and tried to use the script by putting in in the new project folder. for some reason it doesnt work properly. so I deleted it. and when I create and retype a new script and added it, the stupid warning appears. WTF unity.

Compare unity with say 3dRad. scripting in 3dRad is simply load, link to object done. load unload delete no such problems. Unity complicates things too much. Drives me insane. Time wasted on looking for answers to problems that really shouldnt exist.