Phase III Progress Report — New functionality — High score

Luke Duckett
Jun 1, 2021

--

In this quick article I will discuss implementing a high score function with player prefs.

PlayerPrefs are a class which stores simple variables (int, string and floats) with a string key for retrieval. You could think of these almost as a dictorary.

PlayerPrefs generally will not throw an error if the key returns empty data so it is up to the programmer to check for values if required.

In my example I retrieve the value stored under “HighScore” and compare it to the current score.

If the value of score is higher, I will then override the value stored in the PlayerPrefs.

I then pass in the value to my UImanger to show the new high score on the screen.

Now we can see it in action.

Thats all for now.

--

--

Luke Duckett
Luke Duckett

Written by Luke Duckett

🎮 First Nations Unity Dev from Wonnarua country 🏞️ | From Player to Lifelong Learner: Crafting Games, Debugging Code, and Embracing New Technology

No responses yet