Saving game stats
Saving game information is actually very easy. This method works on all devices. The PlayerPrefs
function can save and load player information on the system. All you have to pass in is a key that you will save and retrieve the data and a value that you want to store.
So in your gameScript
, when you increment the value of gameplayCount
 variable and add the following code after it:
PlayerPrefs.SetInt("GameplayCount", gameplayCount);
Now the value of gameplayCount
will be stored in the GameplayCount
key.
To retrieve information, you will use the GetInt
function of PlayerPrefs
to get the value stored in the key. So, before you increment the gameplayCount
variable, add the following code:
int gameplayCount = PlayerPrefs.GetInt("GameplayCount");
Now the value stored in the key in the system for GameplayCount
is retrieved and stored in a local variable called gameplayCount
.
You are now incrementing this value and then saving the new value in the system. Now the system will...