Question by
CodewithFin · Apr 13, 2016 at 06:54 PM ·
c#unity 5highscores
Displaying Local High Scores.
I've been attempting to figure out how to implement a leader board into my main menu for some time now, I've jumped around with some code but nothings working. I already have a script that saves the highest score to player prefs:
public Text scoretext;
public Text hscoretext;
public static int scorecount = 0;
public static int hscorecount;
public int PPS;
public bool SI;
void Start()
{
if (PlayerPrefs.HasKey("HighScore"))
{
hscorecount = PlayerPrefs.GetInt("HighScore");
}
}
void Update()
{
scorecount += PPS * Time.deltaTime;
if (scorecount > hscorecount)
{
hscorecount = scorecount;
PlayerPrefs.SetInt("HighScore", hscorecount);
}
scoretext.text = "Score: " + Mathf.Round(scorecount);
hscoretext.text = "High Score: " + Mathf.Round(hscorecount);
}
But I can't figure out how to save the top five high scores and display them! Any help is appreciated!
Comment
Your answer
Follow this Question
Related Questions
Guys i Need Guidance with high score C# 1 Answer
how to implement online leader board to my project? 0 Answers
error CS0201? 1 Answer
The location of the object by points 0 Answers