Page 1 of 2

Saving, loading on scene change

Posted: Wed Dec 30, 2020 2:20 pm
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.

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 4:39 pm
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);)

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 4:48 pm
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.

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 4:54 pm
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.)

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 5:19 pm
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.

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 5:26 pm
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

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 7:29 pm
by seaniboy2009
No i am not using any of them.

Re: Saving, loading on scene change

Posted: Wed Dec 30, 2020 7:51 pm
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();

Re: Saving, loading on scene change

Posted: Thu Dec 31, 2020 6:26 am
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);

Re: Saving, loading on scene change

Posted: Thu Dec 31, 2020 6:58 am
by seaniboy2009
Its ok sorted it :) thanks again for the help.