Adding Highscore and Score to the GameOver Scene

Hi, once my game has finished I want the score to roll over and display on the GameOver scene. I also want it to show the best score. How could I do this using unity’s new UI Text?

I’m not sure how much detail to give without knowing how well you understand unity.

The quick answer is that you can set the public “text” property.

UItext.text = "string";

But there’s a catch! You have to include the UnityEngine.UI namespace at the top of your code!

using UnityEngine.UI;

Yeah I’m only 14 years old so not very experienced so could you please explain in more detail of exactly what to do if possible? I did know about the adding UnityEngine.UI at the top though :slight_smile: Also I’ve managed to get the score to count up and work on the game scene but I want to display it on the game over scene when the game ends which is what I’m unsure about.

So far I’ve written this and put it on an empty game object in the game over scene. All it does is when the game ends the score labels displays this text " Score: 0" it’s always 0 even though the score of the game wasn’t. How do I fix it so it shows the players score. This is the code:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Highscore : MonoBehaviour {

public Text scoreText;
public float score;

// Use this for initialization
void Start () {

scoreText.text = "Score: " + score.ToString();

}

// Update is called once per frame
void Update () {

}
}