How to NOT reset current scene while loading another?

Hello all,

How to not reset the current scene while the system loads to another scene? As in I would like to save the scene state when the user is currently in another scene and then come back to the previous scene to the last state.

Thanks

I don’t think there’s a built-in way to do that (unless you count “loading scenes additively so that the old scene is never unloaded at all”).

Saving absolutely everything in a scene is (typically) a lot of data, most of which you (probably) don’t need, because a lot of stuff stays the same or only changes in a few ways that you care about.

Usually you should identify just a few key things that you care about and only save those, writing some custom code that can check the current values before unloading and then set things up appropriately after you load again.

Depending on how much you need to save, and how long you want to save it, you might want to serialize the data and put it in a file, in PlayerPrefs, or in some other long-term storage. But if you only need a relatively small amount of information, and only need it while the program is running, you can probably just hold it in memory using static variables or in a GameObject that you’ve set to DontDestroyOnLoad.

2 Likes

If you’re not super tight on memory, then just deactivate all the GameObjects in the old scene, load the new scene additively, and reactivate them when you return.

2 Likes

I can do this, but the thing I am trying to pause are the particles. If I jump to another scene while deactivating these game objects, it would not be in pause state. Looking for some way to hide it while using additive loading.

SceneManager.LoadScene(“OtherSceneName”, LoadSceneMode.Additive);

This might do the trick.

Also, Particles can be resimulated back to the state they were if you set a custom rnd seed for them and then use .Simulate() on the ParticleSystem.