Search Unity

Hidden gameobjects in Unity 5.3 scene hierarchy

Discussion in 'Editor & General Support' started by Reisender, Dec 29, 2015.

  1. Reisender

    Reisender

    Joined:
    Jun 26, 2014
    Posts:
    35
    This new Unity version is driving me crazy...

    Here's a new problem: I have a scene with just 3 gameobjects in it. One of these objects is using legacy UIs to print some information on the screen.

    Now, when I updated to Unity 5.3 (specifically 5.3.1f1, though this also happened with 5.3.0), this gameobject seems to be hidden in the hierarchy.

    I'm pretty sure the object is still there:
    - I have a reference to this object in another game object in the scene. If I double click this reference in the inspector, I can edit the gameobject in question, though nothing is selected in the hierarchy.
    - If I run the scene, the gameobject magically appears in the hierarchy (as if I were using Instantiate to create it, which I'm not). The object disappears again when I stop the execution.

    How do I get back my gameobject?

    The real problem is not this. I could as well recreate this simple scene from scratch. The real problem is that my project has many scenes, each one with much more than 3 game objects. How do I know that other gameobjects have not disappeared from hierarchy?
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    HI,

    Can you file a bug report and attach the project, please.
    Post the bug nummer here and I can take a quick look at it..
     
  3. Reisender

    Reisender

    Joined:
    Jun 26, 2014
    Posts:
    35
    Hi Steen, thanks for your response.

    I've filed the bug. The case number is 757961.
     
  4. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Hi,

    I have replied to your bug report but for the curious I will put my reply here as well:

    I have found the problem. This is a caveat of the new multi scene editing feature.

    In LoadingScreenController.cs you have:
    Code (csharp):
    1.  
    2. private void Awake() {
    3.     DontDestroyOnLoad(gameObject);
    4. }
    5.  
    if you change this to:
    Code (csharp):
    1.  
    2. private void Awake() {
    3.     if (Application.isPlaying)
    4.         DontDestroyOnLoad(gameObject);
    5. }
    6.  
    You will get the expected behaviour.

    DontDestroyOnLoad was never meant to work in edit mode, only at runtime or when entering play mode in the editor.

    With multi scene editing the object marked with DontDestroyOnLoad is actually moved to a separate scene and this why it disappears if you call it during edit mode.

    The plan is to deprecate DontDestroyOnLoad, instead it is recommended to use the multi scene feature to have a separate scene for managers like this.

    Here is a excerpt from the multi scene editing manual page http://docs.unity3d.com/Manual/MultiSceneEditing.html:

    "It is recommended to avoid using DontDestroyOnLoad to persist manager GameObjects that you want to survive across scene loads. Instead, create a manager scene that has all your managers and use SceneManager.LoadScene(<path>, LoadSceneMode.Additive) and SceneManager.UnloadScene to manage your game progress."
     
    Reisender and Corvwyn like this.
  5. Reisender

    Reisender

    Joined:
    Jun 26, 2014
    Posts:
    35
    That solved the issue! Thanks a lot Steen!