// Use this for initialization void Start() { Score = GameObject.FindGameObjectWithTag(ScoreTAG); ScoreGameOverr = GameObject.FindGameObjectWithTag("ScoreGameOver"); HighScorer = GameObject.FindGameObjectWithTag(HighScoreTAG); getPlayerPrefs(); Score.GetComponent <Text>().text = "Score " + Scorer.ToString(); ScoreGameOverr.GetComponent <Text>().text = "Score " + Scorer.ToString(); HighScorer.GetComponent <Text>().text = "" + HighScore; }
// Update is called once per frame public void SetScore(int ScoreToAdd) { Scorer = Scorer + ScoreToAdd; Score.GetComponent <Text>().text = Scorer.ToString(); ScoreGameOverr.GetComponent <Text>().text = "Score " + Scorer; if (Scorer >= HighScore) { HighScore = Scorer; setPlayerPrefs(Scorer); PlayerPrefs.Save(); } HighScorer.GetComponent <Text>().text = "" + HighScore; }