How to Load Scenes in the background for games with HUGE worlds
🕑 Added 2023-10-03 13:01:00 +0000 UTCI wanted to build off the last tutorial that covered data persistence and loading transitions. This one, instead of creating a loading transition while loading the next scene, will actually load/unload scenes in the BACKGROUND off the main thread, so that you can seamlessly load in new scenes without a loading transition.
This method is flexible and easy to implement, and will cover a wide range of use cases.
Really hope you enoy!
Comments
Jude Greaves
I see ! this was a lot of help. Very useful to know for other cases too.
Sasquatch B Studios
You could keep the camera a persistent object and pass in the bound trigger each time you load a new scene, or you could have each scene hold it's own camera and pass in the player as the target (or a different target object if applicable) each time the scene loads in. Either way, the key is to pass data around each time a scene gets loaded - which you can do with the SceneManager.sceneloaded value which can be assigned to a delegate. Link for documentation below: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager-sceneLoaded.html
Jude Greaves
How do you manage persistence with the cameras if you have camera swap triggers and camera bounds?
Sasquatch B Studios
Well sort of, you just actually build the environment in each scene connected to the scenes beside it. It's a habit I got into while making VoM (a metroidvania,) While building actual levels you just have multiple scenes open in the hierarchy at the same time, and connect rooms together that way. Makes things like building an actual organic world that fits together properly MUCH easier, as opposed to creating each scene individually which means you're level building blindly. Also, makes things like creating a map MUCH easier too
AloneOnMars
Thanks for this follow up! It's very informative and will be helpful to me in my own projects. How did you line up your scenes? Was it just changing the transform of the environment itself?