Lesson 6: High Score

In this lesson, we will access the “High Score” and display it on the Lose_Scene


Use the code below to create a new script called HighScore. You will create an empty gameobject called High Score that you will attach this script to. You will then assign a new text object to the scripts variable as in the video below the code.

Wire Up the High Score

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HighScore : MonoBehaviour {
    public Text highScore;
	// Use this for initialization
	void Start () {
        highScore.text = "Jumps: " + PlayerPrefs.GetInt("High Score").ToString();

Project Files

If you cannot troubleshoot your way past any problems. The link below provides a download to the project files up to this point: