The referenced script on this Behaviour is missing! on empty scene

I have three of these errors.
But they remain, even when I delete eveything thats in the hierachy for that scene.

I managed to get this too - but I found a workaround of sorts.

Hit CTRL+A to select everything in the scene; then in the heirachy, unselect everything using CTRL+CLICK on each item (this takes a while. :|), then delete.

Somehow CTRL+A manages to select the item, even though it is invisible to the heirachy.

Hopefully this helps someone else out too.

At that point, I would leave the scene empty, delete the scene, and start again. Hopefully you have backups, so you could copy/paste from the backup to the new scene keeping an eye out for that error. Seems like something in a ‘cache’ or something. But also, do you have an Editor scripts which may depend on something that got deleted?

Okay I got it working. I will let you know my solution. But it may not be the same for you too.

I created script (say ‘A’) and it attach it to a prefab. Now this prefab was attached to the script (say ‘B’) which says there is an error. But later I happen to delete the A script from the project folder but I did not remove the component from the Prefab.

So I removed it. It kinda worked.

Hope it is kinda the same for you too.

add capsule collider in player

My issue was caused by a script setting a gameobject its hideflag to invisible in hierachy. And since it was a emtpy gameobject with a script I had no visual location in the scene vieuw either.
Deleting the script did not reset the gameobects hideflags.
I simply wrote a script that made all gameobjects hideflags to default in the scene.
And could then select them from the hierachy to delete them.
I would post it but I can’t find where I placed it :confused:

I resolved this by:

  • delete the original prefab in the project view
  • dbl click the warning to highlight the object in the hierarchy
  • drag the selected object from the hierarchy to the project view (same place as the original prefab was)
  • drag the prefab back out to the hierarchy view

For me, now the inspector on both of the original object and the prefab displayed the missing script, I just removed the missing script component, deleted the prefab, and warnings are no more :slight_smile:

Hope this helps someone else.