In the last couple of days, I added a way to save the high-score in my game using Unity's PlayerPrefs API.
Also, I improved the end screen of the game.
PlayerPrefs Usage
Using the PlayerPrefs API is very simple. Here's my high-score saving logic looks like:
private bool SaveHighScore(int newScore)
{
int highScore = PlayerPrefs.GetInt("HighScore", 0);
bool gotNewHighScore = newScore > highScore;
if (gotNewHighScore)
{
PlayerPrefs.SetInt("HighScore", newScore);
PlayerPrefs.Save();
}
return gotNewHighScore;
}
Top comments (0)