Purpose of m_addedScenes in LoadAdditiveScene?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
rjb32
Posts: 5
Joined: Sat Jul 04, 2020 11:46 am

Purpose of m_addedScenes in LoadAdditiveScene?

Post by rjb32 »

Hello,

My game revolves around areas that can change fairly drastically depending on what conditions have been met. Not sure if this is best practice necessarily, but the solution I landed on was having a "base" scene, and then any permutations are stored in separate scenes that I add on top of the base with an additive scene load when the player first enters the base scene. These loads are stored in dialogue system triggers on a main controller that triggers a LoadLevel sequence on start if the proper conditions are met.

However, this was causing issues because with the save system active, LoadLevel executes SaveSystem.LoadAdditiveScene, which adds the scene to an m_addedScenes list, preventing the additive scene from being loaded again if I reload the base scene. Not adding the additive scene to that list solved the issue.

So, I'm not super familiar with how the save system works, so before I continue forward with this approach, I wanted to ask -- what is the purpose of m_addedScenes? Will I be causing further headaches down the line if I don't add to that list? Would a better solution be to write some kind of custom LoadLevel sequence that first calls UnloadAdditiveScene?

Any guidance would be appreciated.

Thank you!
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Purpose of m_addedScenes in LoadAdditiveScene?

Post by Tony Li »

Hi,

m_addedScenes keeps track of which scenes have been additively loaded to prevent them from being loaded a second time.

Before reloading the base scene, call PixelCrushers.SaveSystem.UnloadAdditiveScene() to unload the additively-loaded scene.

Or import this patch (which will be in the next full release, too):

PixelCrushers_SaveSystemPatch_2020-09-11.unitypackage

and set:

Code: Select all

PixelCrushers.SaveSystem.autoUnloadAdditiveScenes = true;
Then when you change scenes (e.g., using LoadLevel()), it will automatically unload any additively-loaded scenes that you've loaded with SaveSystem.LoadAdditiveScene().
rjb32
Posts: 5
Joined: Sat Jul 04, 2020 11:46 am

Re: Purpose of m_addedScenes in LoadAdditiveScene?

Post by rjb32 »

The patch works like a charm. Thanks Tony!
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Purpose of m_addedScenes in LoadAdditiveScene?

Post by Tony Li »

Great! Happy to help.
Post Reply