using System; using UnityEngine; public class ScoreService { public int score=0; public int highScore=PlayerPrefs.GetInt("HighScore",0); public void AddScore() { score += 5; if (score>highScore) { SetNewHighScore(); } } private void SetNewHighScore() { highScore = score; PlayerPrefs.SetInt("HighScore", highScore); PlayerPrefs.Save(); } }