Saving, loading on scene change

Announcements, support questions, and discussion for Quest Machine.
seaniboy2009
Posts: 12
Joined: Tue Dec 22, 2020 2:43 pm

Saving, loading on scene change

Post by seaniboy2009 »

Hi, Sorry to ask another question :)

I have set up the save system and seems to work from the main game scene, i can end play mode and run again and everything is saved fine, but if i change to the main menu then click on continue game, it then just loads the scene nothing is loaded, but if i end and play again all the save data is back, is there something stopping it from loading because its a scene change and not starting from play?

thanks.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving, loading on scene change

Post by Tony Li »

Hi,

How are you saving and loading? Are you using an AutoSaveLoad component?

How are you continuing? Loading a saved game? (e.g., SaveSystem.LoadFromSlot(0);)
seaniboy2009
Posts: 12
Joined: Tue Dec 22, 2020 2:43 pm

Re: Saving, loading on scene change

Post by seaniboy2009 »

Yes i am using the autosave function, when you continue game it just loads the scene as normal then easy save kicks in and applies all the properties.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving, loading on scene change

Post by Tony Li »

How are you tying EasySave and Quest Machine's save system into the whole save process. (Apologies if you've described it before. It's hard to remember what every dev is doing in their projects.)
seaniboy2009
Posts: 12
Joined: Tue Dec 22, 2020 2:43 pm

Re: Saving, loading on scene change

Post by seaniboy2009 »

Not a problem, i am using a empty gameobject with all the save systems the autosave and the save and json components then the es3 component you send me, it does work just not when changing scenes. i have not added any scripting for quest machine.

I have scripted in the save on application quit, but the save system work when i change scene just not the journal.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving, loading on scene change

Post by Tony Li »

Are you changing scenes using one of the save system-aware methods? They are:
  • Scene Portal component
  • SaveSystemMethods component's LoadScene method
  • In C#: PixelCrushers.SaveSystem.LoadScene()
  • Or, if you're using the Dialogue System, the LoadLevel() sequencer command
seaniboy2009
Posts: 12
Joined: Tue Dec 22, 2020 2:43 pm

Re: Saving, loading on scene change

Post by seaniboy2009 »

No i am not using any of them.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving, loading on scene change

Post by Tony Li »

Hi,

You will either need to use one of those methods or this:

Before changing the scene, call this C# code:

Code: Select all

PixelCrushers.SaveSystem.BeforeSceneChange();
PixelCrushers.SaveSystem.RecordSavedGameData();
After changing the scene, call this C# code:

Code: Select all

PixelCrushers.SaveSystem.ApplySavedGameData();
seaniboy2009
Posts: 12
Joined: Tue Dec 22, 2020 2:43 pm

Re: Saving, loading on scene change

Post by seaniboy2009 »

that works perfect thank you, does the below still work with es3 or do i need to use another method to delete the save file.

DeleteSavedGameData()

because i am using slot 1 for the save and its not deleting it with this.

Debug.Log("Save exists / Deleting");
ES3.DeleteFile("SaveFile.es3");
ES3.Save("saveExists", saveExists);
PixelCrushers.SaveSystem.DeleteSavedGameInSlot(1);
Loader.Load(Loader.Scene.Main_Game_SinglePlayer);
seaniboy2009
Posts: 12
Joined: Tue Dec 22, 2020 2:43 pm

Re: Saving, loading on scene change

Post by seaniboy2009 »

Its ok sorted it :) thanks again for the help.
Post Reply