Search code examples
unity-game-engineunity-uiscene-manager

Should I use multiple parallel scenes?


I am working on a desktop app based on unity, lets say it looks like a video editor.

I am thinking of using one scene for the preview window and another for the whole UI around it so later I can reuse the preview scene for another application that is linked to this one, in a way.

What are the pros/cons of this method ?


Solution

  • Pros are multiple of course:

    • Better separation: you can have a scene setup for a specific, and only that, purpose; for example, one scene for the UI, one scene for the Main Menu/Options canvases, etc.
    • Improved maintainability: due to separation, it's easier to maintain/test/upgrade/work in general with smaller scenes gameobjects wise.

    In the end, scenes in Unity are nothing more than containers for game objects, similar in a way to what a parent game object is to its children.

    Cons:

    • A little bit of hassle in the editor: you can't get references from one scene to another, the only way to get them is via code by using the Scene.GetRootGameObjects() method, which store all the root game objects of the scene in an array, and from there you can reference those game objects freely. You can however create a wrapper that acts like an observer pattern among scenes, sending events to specific scenes, but this brings to:
    • More organization needed while developing all your systems, due to the lack of reference to objects via Inspector.

    These are just the basic, few things that come off the top of my head, of course there's a lot more to learn, but the time spent in managing multiple scenes projects is well spent imho.