Save and load whole scene

Hello! I don’t know why this has to be so complicated, but I am trying to make a game where I can save what scene the player is on when the game saves, and so that when the player comes back to the game they can load the saved scene.

I don’t want to load the player’s position on that, I just want it to load to the scene the player last saved on.

How do I do this?

You can get the index of the current scene with SceneManager.GetActiveScene().buildIndex and save that in PlayerPrefs. When you start the game, you can load the scene using SceneManager.LoadScene(int index). Be sure to have “using UnityEngine.SceneManagement;” minus quotes at the top of the script.

Ok, this works well with buttons. But how do I make it work automatically?