- Home /
checkpoint level please
Hi , i'm trying to make checkpoint save/load level , like when i'm in level 13 then closing the game then open it i'm still in level 13.
How to do that ???
Answer by Seth-Bergman · Nov 02, 2012 at 08:36 AM
For this you can use PlayerPrefs:
http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
So, for example, every time you advance to a new level, you would save it like:
PlayerPrefs.SetInt("Player Level", currentLevel);
then on the load next time, you just say:
currentLevel = PlayerPrefs.GetInt("Player Level");
Answer by whydoidoit · Nov 02, 2012 at 08:32 AM
It depends really - if its just the level then store the current value in PlayerPrefs with SetInt(Application.loadedLevel) or SetString(Application.loadedLevelName).
Then in your opening scene have an object with an Awake() function that decides whether it should reload, and just read the value out of player prefs.
If you actually want to store more data then you should consider Unity Serializer