From 0dbbf027891461268a4baa2e62a64cf73b9f4e05 Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Thu, 27 Nov 2025 10:56:36 +0000 Subject: [PATCH] Saved player score with PlayerPrefs --- Assets/Scripts/PlayerController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index c64408f..2018369 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -21,6 +21,8 @@ public class PlayerController : OrbitalPositionBehaviour protected override void OnStart() { s_Instance = this; + s_HighScore = Mathf.Max(s_HighScore, PlayerPrefs.GetInt("HighScore", 0)); + Debug.Log($"Loaded high score of [{s_HighScore}]"); GlobalOrbitalPositionManager.SetPlayer(m_OrbitalPosition); @@ -33,6 +35,8 @@ public class PlayerController : OrbitalPositionBehaviour m_ScoreText.text = s_PlayerScore.ToString(); if (s_PlayerScore > s_HighScore) m_ScoreText.color = Color.yellow; + else + m_ScoreText.color = Color.white; if (GlobalInput.IsScreenClicked && GlobalOrbitalPositionManager.AllowPlayerInput) { @@ -65,6 +69,7 @@ public class PlayerController : OrbitalPositionBehaviour m_Renderer.material.color = Color.green; s_HighScore = Math.Max(s_HighScore, s_PlayerScore); + PlayerPrefs.SetInt("HighScore", s_HighScore); s_PlayerScore = 0; }