Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

missing script on a nonexistent gameobject

Discussion in 'Scripting' started by juliang, May 12, 2020.

  1. juliang

    juliang

    Joined:
    Nov 25, 2008
    Posts:
    98
    I'm getting the classic
    The referenced script on this Behaviour (Game Object 'Temp-SceneCreatedMarker') is missing!
    Thing is, there's no such gameobject. I can see the reference in the raw .unity file, but I'm really reluctant to edit that. Is there a prescribed way to get this cleared out?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    You could try creating a new blank scene, open it at the same time as the scene you mention above, and then drag everything from the first scene to the new scene and resave it.
     
  3. juliang

    juliang

    Joined:
    Nov 25, 2008
    Posts:
    98
    Thanks, but, ugh. In the past I've had trouble with that - not all GOs get transferred properly.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    The only time I have seen Unity scenes get corrupted like this is if you open them with a newer version of Unity, then go back to an older version. This is explicitly a Bad Thing(tm) and prohibited, and when it causes an issue, it is generally some unspecified damage to the underlying YAML. If this is indeed what happened, I recommend just rebuilding the scene from scratch, using the old one only as a reference. Anything else is really just not guaranteed to work.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    It is possible the GameObject is actually hidden in the hierarchy.

    https://docs.unity3d.com/ScriptReference/HideFlags.HideInHierarchy.html

    I absolutely HATE it when an asset developer uses this feature. Took me half a day once to figure out and fix a similar issue when I installed an asset from the store which hid a GameObject in my scene and I later removed the asset from the project and started getting these missing script messages. I think I had to write an editor script to hunt it down and unhide it.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    Whoa, Uncle Joe, are you saying that HideInHierarchy can be serialized to disk?! How infuriating would THAT be... wow. yeah, I'd be annoyed if I got tripped up by that too.
     
    Joe-Censored likes this.
  7. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    That's my assumption. I put up with the missing behavior warnings for about a month, primarily because I couldn't find where they were coming from and I had bigger issues to tackle, but one day I had enough of it and burned half the day finding the source :p That's when I even learned of this flag. Wrote a script to just go through every GameObject in the scene and unhide them. There is was! Delete, save scene, close the editor, svn commit! Move on :)
     
  8. juliang

    juliang

    Joined:
    Nov 25, 2008
    Posts:
    98
    Well that did it. Wrote an editor script to clear the flag, and then deleted the GO after being able to see it. Thanks!
    Note to later readers: it has to be an editor script to make sure that the changes get serialized out.