I’ve found myself in an interesting grey area with scene loading since I upgraded into the 5.3s.
Docs recommend:
“It is recommended to avoid using DontDestroyOnLoad to persist manager GameObjects that you want to survive across scene loads. Instead, create a manager scene that has all your managers and use SceneManager.LoadScene(, LoadSceneMode.Additive) and SceneManager.UnloadScene to manage your game progress.” (Unity - Manual: Work with multiple scenes in Unity in Tips and Tricks)
Since I had been using lots of DontDestroyOnLoad, I listened to this and converted to a Manager scene.
Then, I went and updated my scene loading scripts to use SceneManager rather than the newly-deprecated methods (Note, I am using LoadSceneAsync). I see three ways I can implement this, and none is ideal:
-
Don’t persist gameobjects by using LoadSceneMode.Single when moving between major scenes, then have the new scene load in my Manager scene additively each time. Since my Manager doesn’t persist, it’s scripts also get reset each time causing all kinds of problems (a simple example: music script stops playing or restarts from beginning of song). (Unacceptable.)
-
Persist gameobjects by going back to DontDestroyOnLoad, getting rid of the Manager scene altogether, and going against documentation recommendations. (Maybe ideal?)
-
Persist gameobjects by loading a new scene additively, leaving Manager untouched. Here we branch, with both options throwing up anger in the console:
-
Either I unload the current scene before finishing the next, causing a brief lack of audio listeners and a camera-less blank screen. (Unacceptable.)
-
Or, I unload the current scene after finishing the next, causing multiple audio listeners and multiple EventSystems to exist at once. (My current implementation)
So, here’s my question: how can I persist a Manager scene between scene changes without using DontDestroyOnLoad or accidentally having multiple major scenes loaded at the same time, if briefly?