In my game on Unity3d I have many scenes a now I work on the save/load game. I can save the game, but if I want to load it, I need to load scene, which I need, then load all other parameters.
Or should I load all parameters first, save it with DontDestroyOnLoad()
and then load scene, which I need?
public void ButtonSave()
{
PlayerPrefs.SetFloat("transform position x" + currentActiveSlot, playerTransform.position.x);
PlayerPrefs.SetInt("task 1 completed" + currentActiveSlot, isTask1Completed);
PlayerPrefs.SetInt("latestSaveSlot", latestSaveSlot);
PlayerPrefs.SetInt("act number" + currentActiveSlot, 0);
PlayerPrefs.SetInt("step number" + currentActiveSlot, 0);
PlayerPrefs.SetString("sceneName" + currentActiveSlot, SceneManager.GetActiveScene().name);
PlayerPrefs.Save();
}
public void ButtonLoad()
{
playerTransform.position = new Vector3(PlayerPrefs.GetFloat("transform position x" + currentActiveSlot),
PlayerPrefs.GetFloat("transform position y" + currentActiveSlot),
PlayerPrefs.GetFloat("transform position z" + currentActiveSlot));
isTask1Completed = PlayerPrefs.GetInt("task 1 completed" + currentActiveSlot);
//gameManager.currentActNumber = PlayerPrefs.GetInt("act number" + currentActiveSlot);
//act_2.stepNumber = PlayerPrefs.GetInt("step number" + currentActiveSlot);
//SceneManager.LoadScene(PlayerPrefs.GetString("sceneName" + currentActiveSlot));
}