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;
}
↧