Quantcast
Viewing all articles
Browse latest Browse all 68

Answer by dubbreak

You are setting them to equal before you check so they are always going to be equal. In Start() (which happens every time that script is enabled) you are setting the player prefs score to your current score. So when you check in getHighScore they are the same. Try commenting out the initial set: void Start() { //PlayerPrefs.SetInt("Player Score", Player.Score); getHighScore(); } That way if will only update the player prefs score if the player's current score is higher than the previously saved one. Also from a style standpoint you should name getHighScore something like UpdateHighScore or UpdatePersistentHighScore. Functions that use the verb "get" generally return something. Set high score might be ok as well. Just a critique (which most people take poorly), so please disregard if that's the way you like it.

Viewing all articles
Browse latest Browse all 68

Trending Articles