Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

HideFlags.DontSave completely disables GameObject, Start() and Awake() are not called on scripts

Discussion in 'Editor & General Support' started by Deleted User, May 29, 2015.

  1. Deleted User

    Deleted User

    Guest

    In Unity 5, when setting HideFlags.DontSave as a GameObject's hideFlags, the scripts of that GameObject will not work properly. Specifically Awake and Start are never called, possibly the other functions aren't either.

    To reproduce, just create a script that prints something in Start() and place it on a GameObject. Create an editor script that sets the GameObject's hideFlags, start the scene and voilá.

    Is there a known workaround? I really need HideFlags to (you won't guess) work around another Editor issue that prevents me from porting my game to Unity5.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Setting those flags causes the object to be deleted from the scene, hence no script code will be executed for it.
     
  3. Deleted User

    Deleted User

    Guest

    I don't understand, why would it be deleted? I still see the object and script in playmode, except it's not executed.... Is all this documented anywhere?
     
  4. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    I've never use those, but the docs seem to say that the change behavior after destruction. I would expect everything behave normally prior to destruction. Sounds like a possible bug.
     
  5. Deleted User

    Deleted User

    Guest

    Indeed it seems like a bug, that's why I asked here, hoping for a solution.
     
  6. Deleted User

    Deleted User

    Guest

    Also, these objects cannot be found using Object.FindObjectOfType which is pretty annoying...