load multiple scenes at once and switch without destroying

Hi All,
new to Unity and have asked a few questions related to this in the past couple of weeks. But now I’m finally test programming and watching tutorial videos I’m a bit confused.
So my question is, as per title, can I load multiple scenes “at once” and then select scene without destroying others. My layout is

central Hub scene
|
World 1 hub world 2 hub
| |
mini scene 1 mini scene 1
mini scene 2 mini scene 2
mini scene 3 mini scene 3

Game loads Hub scene, one select world 1 , 2 … is loaded instantly after load it then async loads all three mini scenes, player selects mini game, plays mini game, returns to world hub, then can select any mini game again.
So I only load mini scenes once at entry to the world hub. On leaving world hub, world and mini games are destroyed, player returns to central hub and selects a world, and repeat above.

I though I could use async load, but on reading tutorials forums, I’m now confused, some people are saying async is just for loading bars between scene switches, some are saying when switched you destroy former scene, etc. I think my confusion is caused by so many answers on the net for older versions of Unity.

So basically is it possible to load multiple scenes and switch without destroying the other scenes. If so can anyone point me to a tutorial. Thanks

Should add I’ve read through tutorial Scene Management in Unity 5 - Alan Zucconi
Which seems to indicate you can only have one loaded at a time

"Ghost scenes. Every time you load a new level with SceneManager.LoadScene, Unity flushes all the scenes that have been previously loaded. Only game objects that invoked DontDestroyOnLoad (documentation) survive the process."

That’s not necessarily true. You control this via the optional ‘mode’ parameter (see the docs). If you set this to LoadSceneMode.Additive, then the new scene objects are added to the current scene.

So you could have each of your mini-scenes set up with all objects inside some root object whose name you know (e.g. “MiniScene1”, “MiniScene2”, etc.). That object should be initially inactive. Then you can load them all up with LoadSceneMode.Additive, and call SetActive to switch quickly from one to another.

There’s also SceneManager.SetActiveScene, but it is essentially undocumented, and it’s not at all clear to me what that actually does.

6 Likes

Thanks for the advise :slight_smile: I,ve been looking at scenemanager, but like you I can find little advise on it, even when I google it seems to be people writing their own scene manager. The only tutorial I could find was the one in the post about. But He / She gives up before the show how to use the manager to load multiple scenes :s

Here’s the new scene manager scripting reference for people like me coming in from a search engine: Unity - Scripting API: SceneManagement.SceneManager.LoadScene

Hey folks, also found this:

helped me to wrap my head around this and it still works (2018.2.0b11) \o/

1 Like

Regarding what SetActiveScene does, I also found this thread (note response #14):

The active scene becomes the basis for global scene settings as well as the target for instantiated objects.

Just don’t forget that a scene loaded additively means all scenes are still active, even after using SetActiveScene to switch views. So if you have a main scene and then additively load a mini scene like a side game, the controllers in both scenes will be active.

2 Likes

Ok since this topic is very niche but important for me i gotta ask, the documentation for the overall implementation states that when loaded additively its gonna replace my main scene, but i want it to be displayed on a part of my gui so how would I archieve that? Cant wrap my head around that.