Search Unity

The referenced script on this behaviour is missing during LoadLevel [Solved]

Discussion in 'Editor & General Support' started by Gamieon, Oct 17, 2013.

  1. Gamieon

    Gamieon

    Joined:
    Mar 20, 2010
    Posts:
    38
    For the past few days I've been dealing with a puzzling issue: Every time I called Application.LoadLevel to change the scene in my game, this would appear in my console window:

    The referenced script on this behaviour is missing!

    This is despite the fact that I had no missing scripts! Based on my own logging, I determined this was happening before the next scene was loaded. I ultimately found that there was an internal issue with the prefabbed objects in the scene that was to be loaded (the ones that show in blue in the hierarchy window).

    I was able to eliminate the warning by:

    1. From the editor, open the scene that was to be loaded during the game.
    2. Go through every prefabbed object and Revert to the original prefab state.
    3. Go through every prefabbed object and change all the object properties back to the way I wanted them.

    It was a bit of tedious work, but the warning stopped appearing after that. My guess is this happened because I deleted a script without detaching it from some of my prefab assets first.



    I hope this helps someone out there who may be experiencing the same problem and just can't pin it down!
     
    jamaster96 and CanisLupus like this.
  2. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Thanks! Based on your suggestion, I reverted the only prefab instance I had in the scene being loaded to its original state, and the warnings when loading that scene were gone. In my case, the prefab instance was already exactly the same as the original. Scripts, references, etc. But even then, reverting seems to have fixed it.