How to save which additive scenes are currently loaded?

Announcements, support questions, and discussion for Quest Machine.
Post Reply
FableTech
Posts: 3
Joined: Wed Sep 01, 2021 7:02 pm

How to save which additive scenes are currently loaded?

Post 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
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
Post Reply