Saving issue

Announcements, support questions, and discussion for the Dialogue System.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Saving issue

Post by SealDev »

I have a Main Menu.

If I check "Restore Save on Start", it reloads last level. (wanted behavior)

However, it skips past main menu when I restart the game. (unwanted)

If I quit and restart the game from Main Menu SaveSystemMethods.LoadOrRestart creates an infinite loop of loading the Menu instead of the last scene of the game. (i need to ignore the main menu scene)

How to load the last scene I was in, but only once I hit a "Play Game" button from the main menu?
Last edited by SealDev on Sun Aug 01, 2021 3:01 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving issue

Post by Tony Li »

Hi,

It sounds like you're using the AutoSaveLoad component. Since you have a "Play Game" button, UNtick Load On Start.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: Saving issue

Post by SealDev »

I edited the post to clarify my issue.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: Saving issue

Post by SealDev »

Ok it works when I quit the game!

But it doesn't work when I press Escape to open a Escape Menu, then press Main Menu button then Play Game again.

The "Main Menu" button actually triggers a Dialogue Trigger with sequencer command LoadLevel(Menu) so im surprised it doesnt save
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving issue

Post by Tony Li »

Hi,

Are you using an AutoSaveLoad component? If so, make sure to add your main menu scene's index to the Don't Save In Scenes list.

On what script or component are you ticking Restore Save On Start?

> How to load the last scene I was in, but only once I hit a "Play Game" button from the main menu?

1. If you're using AutoSaveLoad, untick Load On Start.
2. Configure the Play Game button to call SaveSystemMethods.LoadOrRestart.


> But it doesn't work when I press Escape to open a Escape Menu, then press Main Menu button then Play Game again.
> The "Main Menu" button actually triggers a Dialogue Trigger with sequencer command LoadLevel(Menu) so for some reason it doesnt save on scene change

It's not supposed to save on scene change unless you tell it to. You can configure your Main Menu button to call SaveSystemMethods.SaveSlot and then SaveSystemMethods.LoadScene.
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: Saving issue

Post by SealDev »

>Are you using an AutoSaveLoad component?
Yes

>If so, make sure to add your main menu scene's index to the Don't Save In Scenes list.
I did.

>On what script or component are you ticking Restore Save On Start?
On Dialogue System Saver, as well as any other position, enabled, active savers in the scene.

> 2. Configure the Play Game button to call SaveSystemMethods.LoadOrRestart.
This is what it calls now.

> You can configure your Main Menu button to call SaveSystemMethods.SaveSlot and then SaveSystemMethods.LoadScene.
Doing this partially works. I have Lv1 and Lv2. Now when I press "Play game" it always loads Lv1 and everything that is saved in Lv1 works, however if I quit in Lv2 and load game, it still loads Lv1. (so last scene only thing not being saved)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving issue

Post by Tony Li »

UNtick Restore State On Start. That's for a very specific purpose and will cause problems otherwise, which is why it's unticked by default.

Make sure the Save System component's 'Save Current Scene' checkbox is ticked.

Also make sure all saver components have unique Key values. However, identical saver components on the player GameObject in every scene should have the same Key -- for example, if the player GameObject has a PositionSaver, the PositionSaver's Key should be the same for the player GameObject in all scenes.

After making those changes, clear your old saved game(s). Then test again. If something doesn't work, let me know if there are any warnings or errors in the Console window?
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: Saving issue

Post by SealDev »

Solved, thanks :)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving issue

Post by Tony Li »

Glad to help! :-)
SealDev
Posts: 85
Joined: Thu Jun 24, 2021 5:45 am

Re: Saving issue

Post by SealDev »

I have decided to add character customization to my game.

My menu scene contains the character and what he is wearing.

But with the solution above, the save file is loaded only when clicking the "Play" button. Which means the "Main Menu" scene will only show the character with default clothing because it won't load the first time! This also means that when I exit from the game back to the Main Menu, it WILL show the right clothing.

If I use the approach of insta-loading the save file on start, it skips past the main menu scene (unintended behavior)

So, is there a way to load the game on start, so I can see my character customization, but only load the last scene and data where I left off when I click "Play"?
Post Reply