Tracking high score

One more thing that would be good to have in our game is tracking the player's high score. For this, we not only need to keep the high score of the current session, but then persist that data so it's preserved for the next time you play.

First, we'll make a UI element to display the current high score. It will be easiest to simply duplicate the ScorePanel we just made and modify it:

  1. Select the ScorePanel in Hierarchy and duplicate it (right-click and select the option Duplicate).
  2. Rename it HighScorePanel.
  3. Set the Rect Transform to Left: -120, Top: 50, Right: 120, Bottom: -50.
  4. Rename child ScoreTitle to HighScoreTitle.
  5. Change its Text to High Score.
  6. Rename child ScoreValue to HighScoreValue.
  7. Set Font Style to Bold and ...

Get Augmented Reality for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.