I’m trying to have all the scenes in my game load additively. I have one scene that will always stay loaded which will contain the game’s manager script, main camera, and such. And every level will just be loaded as an additive scene.
I’m trying to set up this basic system, and I’m realizing that I’m going to have a problem when I make a call from in the game to return to the title screen. At that point, I need to unload EVERYTHING except for the master scene.
How do I go about doing this in any kind of effective manner?
I thought maybe I could write a loop that will tell all scenes to unload. But I how do I effectively track what scenes are loaded? And what if a scene were currently loading async? Like if the player decided to quite just after triggering a load command? Then this system wouldn’t detect that scene as being loaded (because it isn’t yet) and then it would get loaded.
I also thought I might just tell the game to load the master scene again, in a basic/non-additive manner. Then Unity would run its normal system of unloading everything. But if I wanted a normal game to do anything at the very beginning (like show a logo for my studio, or play an attract of some kind) then this would be executed again, when I would really want the game to bypass such elements and go straight to the title. Unity recommends that I don’t use “Don’t Destroy on Load” if I’m using multiple scenes like this; so how would I retain a variable to let the game know to skip all the intro stuff?
Also, on the subject of unloading scenes, is there any problem with not waiting for a scene to finish unloading? The straight “unloadScene” is marked obsolete, so I’m only supposed to unload scenes async. Off the top of my head, maybe if I immediately start loading a new scene I would be putting a lot into memory for a couple frames. Depending on the platform that might be a problem, although I doubt I’d have enough game content to crash a console doing that.