Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Loading scene vs. instantiating prefabs - which is more efficient?

Discussion in 'Editor & General Support' started by Clicksurfer, Aug 10, 2020.

  1. Clicksurfer

    Clicksurfer

    Joined:
    Aug 17, 2014
    Posts:
    76
    Heya,

    I'm planning out my next game which will be a 2D mobile game with many levels.
    Because of this, I've run into the tried-and-true debate of what is the best way to make many levels for a game.

    From what I gather there are 3 major ways going about this:
    1. Making each level a different scene
    2. Making all levels in the same scene and enabling/disabling gameobjects in it to use different levels
    3. Store level data in a text file and load it to generate a level on the fly inside the scene
    My question is about comparing option 1 to option 3 -
    Assuming I have prefabs of everything, a text file with level data and a script for instantiating a level based on that data, would instantiating the level this way be more, less, or about the same CPU-intensive as simply loading a scene with all those objects inside?

    I'd love to hear if you have an answer regarding this question, as well as any opinions regarding options 1 to 3.
    Thanks!
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    5,859
    CPU-wise it's probably about the same. You are still instantiating the same number of objects. This is more of a developer workflow question.
     
  3. Clicksurfer

    Clicksurfer

    Joined:
    Aug 17, 2014
    Posts:
    76
    I see. I figured as much - just wanted to make sure. Thank you :)
     
unityunity