Persisting the new appearance
PlayerPrefs is a class in Unity3D that is used to store player configuration data. It allows developers to save and load persistent values on the user’s device, meaning that the values will be retained after closing and reopening the game.
It is useful for saving information such as audio settings, player high score, game progress, and other player data. It can also be used to create a personalized experience for the player, for example, allowing them to choose their own username or the color of their character; in our case, it will be the selected avatar.
To use PlayerPrefs
in your Unity3D project, simply call its static methods to save and load data. For example, to save the player’s high score, you can use the following code:
int highScore = 1000; PlayerPrefs.SetInt("HighScore", highScore);
And to load the previously saved high score, you can use the following code:
int savedHighScore = PlayerPrefs.GetInt("...