Search Unity

Load various scenes vs creating prefabs

Discussion in 'General Discussion' started by mx3307, Sep 24, 2019.

  1. mx3307

    mx3307

    Joined:
    Jul 8, 2019
    Posts:
    8
    Hi!

    I realized that performance for smartphones is something REALLY important, therefore while designing a game I came across many performance issues.

    There are some gameObjects that are shared between various scenes. Is it better to use the load various scenes option or is it better to create prefabs of these elements and load them in each scene?

    I have searched for performance about this but have not found any.

    Is there a place specially about performances? How could I know more information about performance?
     
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    I mean, once the scene is loaded, there's no difference between the loaded scene's contents and the instantiated prefab's contents, performance wise.

    Loading a scene is slower, since it loads its contents from memory. A prefab loads from memory when a reference to it is loaded.

    In other words, use scenes for big things, and prefabs for small things. You can also use Addressables to have more control over when assets are loaded from memory.
     
    Ryiah and mx3307 like this.
  3. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Have unity fixed GI for prefabs? If not there is no option but to use scenes if you need for example baked lighting
     
    mx3307 likes this.
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    They still haven't implemented baking for prefabs, which is incredibly frustrating.
     
  5. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    And for scenes loaded additive light probes are broken last time I checked.
     
  6. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    For UI and the like, in previous Unity releases I strongly preferred separate scenes because I found them a lot easier to work with. The new prefab workflow is pretty sick though, and makes them a lot more stable and harder to screw up.

    Lost a bit of the ease of use, but makes up for it in making it suitable for stuff like more complex gui.
     
    Ryiah likes this.
  7. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    Apparently this is fixed in 2019.3, I believe
     
    AndersMalmgren likes this.
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I believe Unity still has a 4GB limit on content referenced in a single scene. If you're dealing with above 4GB of content then you should use the multiple scene approach.
     
  9. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    To add to this, I suggest OP never load even close to 4GB in a single scene.

    Even if you know you need 4GB of stuff, split it into multiple and load them additively and asynchronously. Its far less likely to cause problems that way, and gives you more fine grained control over loading such as being able to load certain things first easily, as well as provide progress reporting on loading to the user at a more fine grained level (think being able to say "loading props - 20% total progress - 80%" instead of just "loading 80%"
     
    mx3307 and Joe-Censored like this.