Storing data
In this section, we are going to cover how we are going to store our data, such as the game's volume settings so that when we play our game, we don't have to keep setting the volume settings to where they were before. We want the game to remember them for us.
There are multiple ways we can store data. The ones we are going to cover are the two most common choices for Unity development. They are as follows:
- PlayerPrefs: This is short for Player Preferences. We can use this to store strings, floats, and integers on the device we are playing our game on. We will be using
PlayerPrefs
shortly to save our volume settings so that when we turn our game off and back on, it will remember our settings.PlayerPrefs
is easily accessible from outside the game with a text file reader. When it comes to development, make sure you don't usePlayerPrefs
to store sensitive information such as credit card details or things that would give a player an unfair advantage...