Search Unity

Instantiate on Startup or setup scene

Discussion in 'Scripting' started by m4rtin-t, Jun 14, 2019.

  1. m4rtin-t

    m4rtin-t

    Joined:
    Jan 30, 2016
    Posts:
    8
    Making a smaller game with a group
    Need to add a few managers in the scene.
    The flow would be like Menu -> click start -> loads game scene.

    Is it better to have one script that instantiates the managers when the game scene loads
    or is it better to just attach those managers to the scenes, so it's already on the scene when the scene loads?

    I know instantiating like 3 manager objects (only has an script attached to the gameobject and nothing else) won't make much of a difference in terms of load time, but in theory does attaching them onto the scene have a faster load time when changing from one scene to another?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,744
    Really depends what your manager does: does it have a huge initial load, maybe even pulling content from the internet? Then load it once and keep it. Is it super-thin and lightweight? Load it as you want.

    The main thing I observe is that this smells like "optimization done WAY too early," and poor decisions resulting from this often plague a project for the rest of its life.

    Keep it simple, refactor it when you need, and be aware of performance issues as you go, as you actually gain intel on what kind of performance issues there ACTUALLY are, not SPECULATIVELY.
     
    m4rtin-t likes this.