I have a score displayed constantly in my game, but I can't get it to work for my game-complete screen? Help?
In my game, I have points and doors. When you grab a point, your score goes up by x. When you pass through a door, your score goes up by y. The score is displayed on the top-middle of my game - this all works properly. When you pass through the final door, a white screen fades in, shortly followed by:
Game Complete You Scored: Z
Where Z = your total score and each line is its own seperate text in a UI canvas panel thing. I tried to copy+paste the same script I use to display the score through the game onto the 'Z' text, but it won't work. Please help?
Score (displayed during game) Script:
using UnityEngine; using UnityEngine.UI;
public class Score : MonoBehaviour { public int score; public Text scoreText;
public void AddScore(int a)
{
score += a;
scoreText.text = score.ToString();
}
}
Score (displayed after game completed) Script
using UnityEngine; using UnityEngine.UI;
public class FinalScore : MonoBehaviour { public int score; public Text scoreText;
public void Update ()
{
scoreText.text = score.ToString();
}
}