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

Difference between active/inactive GameObjects and Additive Scenes

Discussion in 'Editor & General Support' started by JudahMantell, Jan 21, 2019.

  1. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Just as the title says: What's the practical difference between toggling certain large chunks of a level on or off (childed to an empty GameObject), and loading and unloading a level additively all in the same 3d space?

    Is it better for performance to do one over the other? I'm specifically using VR, but I have a feeling that's not relevant. Thanks! :D
     
  2. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @MidnightCoffeeInc Those two are conceptually very different. Unloading a Level will in many - not all - cases also unload any assets and reduce Reference Counts.

    A Scene is much more than only the game objects in it. Disabling gameObjects keeps all of them in memory. A Scene is also it's lighting, it's state, etc. You can not really compare those two.

    Disabling a gameObject is usually way faster than unloading a scene - but it has a drastic different implication for many things. It is still there. It is just not active.

    However, the important thing is: Is it really relevant in your case? Profile it.
     
  3. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Ah, understood. Thanks so much for clarifying!
    I will definitely get to testing things out with the profiler. Thanks so much!
     
    MNNoxMortem likes this.
  4. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    This might be a topic for another thread, but since it's being discussed (sorta!), how would I serialize which scenes are loaded and unloaded so I can load them later?
    Like, I know how to save player position (x, y, and z variables), but if the player/managers are in one persistent scene, while the actual world is split up into different additively loaded scenes, how would I "remember" which ones are active? Via saved bools that I will then check on startup?
    I apologize If this is meant for a different thread!

    Thanks so much!
     
  5. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @MidnightCoffeInc that is easy. Simply serialize string scene.name and string activeSceneName = SceneManager.GetActiveScene().name.

    Also always split your stored information. Save the player position separated from the active scenes. It helps a lot extending the system. Keep your data separated the same way you logically separate your systems by concern.
     
  6. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Cool, thanks!
     
    MNNoxMortem likes this.