From 81cce75bea25252286342aa34769c5e28162611b Mon Sep 17 00:00:00 2001 From: nexovec <30555041+nexovec@users.noreply.github.com> Date: Sun, 30 Jan 2022 14:45:57 +0100 Subject: [PATCH] fixed highscore not loading --- Assets/Scripts/UiController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index bf193e2..7160e62 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -16,7 +16,7 @@ public class UiController : MonoBehaviour public static bool isInMenu = true; public static float distance = 0; - public static int highScore = 0; + public static float highScore = 0; private float oldDistance = 0.0f; // Start is called before the first frame update @@ -71,9 +71,13 @@ public class UiController : MonoBehaviour if (oldDistance < distance) { uiDistance.text = "Distance : " + distance.ToString("0"); - uiHighScore.text = "HighScore : " + UiController.highScore.ToString("0"); oldDistance = distance; + if (distance > highScore) + { + highScore = distance; + } } + uiHighScore.text = "HighScore : " + UiController.highScore.ToString("0"); } public void FixedUpdate(){ this.menuCamera.transform.position = this.menuCamera.transform.position + Vector3.forward * 0.05f;