Hi,
I want to create preload function in main menu for last saved scene.
I try to access to saved file current scene index but some how I always get -1.
Am I doing something wrong?
private int GetSavedScene()
{
var saveFile = KickStarter.saveSystem.GetSaveFile(1);
var playerID = saveFile.profileID;
var playerData = KickStarter.saveSystem.GetPlayerData(playerID);
return playerData.currentScene;
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
After a couple test I realize that
line is wrong now I try to get playerID from MainData but how can I access to playerID from SaveFile.
Okay I got it, just not forget to use System.IO;
The SceneData array only contains data related to each scene - it's not representative of which scene is actually open.
Instead, you have to get the playerID and iterate through the PlayerData array to find a match.
This function will let you get the saved scene index: