Hello everyone , im making a mobile game and i have score but there is no highscore im not making online leaderboard thing , it’s my normal score code ;
void StoreHighscore(int newHighscore)
{
int oldHighscore = PlayerPrefs.GetInt("highscore", 0);
if(newHighscore > oldHighscore)
PlayerPrefs.SetInt("highscore", newHighscore);
}
and this code attached to the Game over screen ;
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
public GUIStyle style;
void OnGUI()
{
GUI.Label (new Rect (50, 50, 1000, 500), "Score : " + PlayerPrefs.GetInt("SaveScore") , style );
//display saved score
}
}
Any idea how to make high score ?