Load Game From Slot - Persistent Scene

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wkjp213
Posts: 4
Joined: Tue Jan 10, 2023 8:31 pm

Load Game From Slot - Persistent Scene

Post by wkjp213 »

Hi there!

I have a Persistent Scene that is loaded by default when the game is started, the "Main Menu" is an object on this scene which is active while the rest of the game components are inactive (main game UI, player, etc.).

When I load a save from a slot with SaveSystem.LoadGameFromSlot I want it to load the scene that the game was saved in additively, and then make that scene the active scene, leaving the persistent scene loaded but no longer considered the primary scene.

It seems like when I call the SaveSystem.LoadGameFromSlot it's unloading my persistent scene and loading the saved scene, which of course is causing all kinds of errors because the persistent scene has all the game components, player, etc.

Is there an easy way to configure this that I may just be missing?

Really loving DS, QM, and LH so far! Excited to get over this hump.
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: Load Game From Slot - Persistent Scene

Post by Tony Li »

Hi,

There are two ways to handle that currently:

1. Mark the root GameObjects in your Persistent Scene as Don't Destroy On Load. They won't be unloaded when calling SaveSystem.LoadFromSlot(). You can add a Don't Destroy GameObject component to these GameObjects.

2. Or UNtick the Save System component's Save Current Scene checkbox. Handle scene loading yourself. You can still get the last scene the player was in like this (example):

Code: Select all

var savedGameData = SaveSystem.storer.RetrieveSavedGameData(slotNumber);
SceneManager.LoadScene(savedGameData.sceneName);
SaveSystem.ApplySavedGameData(savedGameData);
wkjp213
Posts: 4
Joined: Tue Jan 10, 2023 8:31 pm

Re: Load Game From Slot - Persistent Scene

Post by wkjp213 »

This is great thank you! It's pretty much working perfectly with your second option. I'm not sure why I didn't put that checkbox with the idea of loading the scene but thank you for the clarification.

Loving all your products/engines and the support!
User avatar
Tony Li
Posts: 21962
Joined: Thu Jul 18, 2013 1:27 pm

Re: Load Game From Slot - Persistent Scene

Post by Tony Li »

Thanks! Glad to help.
Post Reply