Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Player prefs easy highscore?

$
0
0
I have read many pages on here about playerprefs, but what I'm thinking should work is not working. I want to set the highscore to 500 if there isn't a highscore in the player prefs already. The highscore will be saved as "monday1" in the prefs. It seems so simple, but its not working. Please help. #pragma strict var highScore: int; function Awake() { if (!PlayerPrefs.HasKey("monday1")) { Debug.Log("there is no key, it is now set to 500!"); PlayerPrefs.SetInt("monday1", 500); } } function Start() { highScore = PlayerPrefs.GetInt("monday1"); guiText.text = "High Score: " + highScore; }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>