[postlink]
https://the-best-way-of-life-is-islam.blogspot.com/2015/07/unity-5-playerprefs-saving-in-unity-but.html
[/postlink]
I have this attached to my hero object that gets destroyed . Could that be part of the problem? All I want to do is save the highscore then display it on my start scene. Here is the code:
public int highscore;
public int score;
void AddPoint1()
{
if (score > highscore) {
highscore = score;
PlayerPrefs.SetInt ("highscore", score);
PlayerPrefs.Save ();
}
}
Here is second script attached to empty object in start scene (different scene)
void OnGUI()
{
GUI.Label (new Rect (Screen.width / 2, Screen.height/2, 100, 100), "Highscore: " + PlayerPrefs.GetInt("highscore"), customGuistyle);
}
Enregistrer un commentaire