Page 1 of 1

Calling the scene from my saved file

Posted: Thu Jan 27, 2022 3:28 am
by baxta86
Hi Tony,

Wondering how i can call the scene which is in my saved file? Looking through the docs, I found this under SavedGameData: String PixelCrushers.SavedGameData.sceneName

How can I go about calling it, or assign it to a variable, if I were loading a scene in a custom script? As in, something like:
Application.LoadLevel(PixelCrushers.SavedGameData.sceneName)

I'm still learning coding, and when i try this code, i need to add an object reference - but not sure how to reference my save file as opposed to creating a new reference of SavedGameData?

If it's not too much trouble, it would be good to know how to access other data in the save file as well (values from the keys)

Hope that's clear....

Re: Calling the scene from my saved file

Posted: Thu Jan 27, 2022 8:59 am
by Tony Li
Hi,

Get the saved game data and access its sceneName field:

Code: Select all

SavedGameData savedGameData = SaveSystem.storer.RetrieveSavedGameData(slotNumber);
Debug.Log("Game was saved in scene: " + savedGameData.sceneName;

Re: Calling the scene from my saved file

Posted: Thu Jan 27, 2022 10:08 pm
by baxta86
Perfect! As always, thank you for your help :)

Re: Calling the scene from my saved file

Posted: Thu Jan 27, 2022 10:18 pm
by Tony Li
Happy to help!