- The UnityEngine.SceneManagement namespace should be included in every source file that changes scenes or needs access to the current scene
- The Awake event is used to retrieve the last level reached using PlayerPrefs to return two values: the highest-level number and the level name associated with that
- HighestLevel is compared to CurrentLevel, and where CurrentLevel is less, a Scene change occurs to load the Highest level
- If the active level is the highest, then this value is saved to PlayerPrefs
Add the LevelSaveRestore script to an empty object in the scene for each and every scene. For each scene, assign the script a number reflecting the level's order in progression. The first level is 0, the next is 1, the next is 2, and so ...