Page 1 of 1

How to save which additive scenes are currently loaded?

Posted: Wed Sep 01, 2021 7:25 pm
by FableTech
Hello,

Our scene configuration is setup with a Global scene that is always loaded, and we additively load specific levels as needed. It seems that the Save System only ever records the non-additive scene in its data:

"m_sceneName": "GlobalScene"

How can we configure the Save System to store and load the additive scenes that were active when the last save occurred?

Thanks in advance,
Fable

Re: How to save which additive scenes are currently loaded?

Posted: Wed Sep 01, 2021 9:41 pm
by Tony Li
Hi,

You can write a Saver component that saves SaveSystem.addedScenes, which is a list of the names of scenes that have been additively loaded by SaveSystem.LoadAdditiveScene(). (SaveSystem.LoadAdditiveScene(x) calls UnityEngine.SceneManagement.SceneManager.LoadScene(x, LoadSceneMode.Additive), but it also updates the added scene with its save data.)

Quest Machine includes a starter template script named SaverTemplate.cs. Duplicate this script and customize it where indicated. In RecordData(), return the list of added scenes. In ApplyData(), use SaveSystem.LoadAdditiveScene() to load those scenes.