I have a top down dungeon crawler in 3D where I show one room at a time. Each room is it's own unity scene. Each room has an exit point that when clicked I fade the screen, load a new scene and then fade in the screen. What I'd like to do, but not sure how, is to pre-load the next possible scenes (note the S, there will be 2 but could be more. 2 because it's the next room or the previous if the player decides to go back) while in one scene. I know the scenes that are possible to get to, but how can I pre-load but not show them and because there is more than 2, I assume if they go in one direction, there is a pre-loaded one that I need to unload. Overall I want to do this to make a faster/smoother transition between rooms, but I want the one room at a time for artistic style.


1 Answer 1

  1. Parent everything in each room's scene to one (or a few) root GameObject(s) that can serve as a point of reference for the room as a whole.

  2. Place a script on these roots with an Awake() method that switches off its own GameObject using gameObject.SetActive(false); - Now as soon as the room is loaded, it will disable its own rendering & gameplay before it has a chance to affect anything or appear on screen.

  3. When it's time to show that room, re-enable its root object(s) with gameObject.SetActive(true);

    Your roots' Awake methods can register them with the corresponding exit points from the main room, so they're easy to find when you need to show them or unload them.

  • 1
    \$\begingroup\$ One thing to note, be careful how many layers deep you nest though as every time an object moves it notifies every object up the chain to the root object. Just an optimization thing to keep in mind. I like the approach though and might use it in my own projects. \$\endgroup\$
    – Tyler C
    Oct 13, 2017 at 19:06
  • \$\begingroup\$ Profile first to see if this becomes an issue — so far I haven't seen significant impacts from hierarchy depth in any Unity game I've worked on. If it does begin to pose an issue, you can simply add to the disabling script to have it find all its dynamic children and dump them into the top level of the scene when needed. ;) \$\endgroup\$
    – DMGregory
    Oct 14, 2017 at 3:24
  • \$\begingroup\$ I have actually seen that used. Unity had a blog post about it. \$\endgroup\$
    – Tyler C
    Oct 14, 2017 at 3:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .