public void CheckForHighScore(){
finall = PlayerPrefs.GetInt("score");// taking score variable from another script to pass in ScoreBoard
for (int x = 0; x < highScores.Length; x++){
if (finall > highScoreValues[x]){
for (int y = highScores.Length - 1; y > x; y--) { //sorting
highScoreValues[y] = highScoreValues[y - 1];
}
highScoreValues[x] = finall;
DrawScores();
SaveScore();
PlayerPrefs.DeleteKey("score");
break;
}
}
}
void DrawScores() {
for (int x = 0; x < highScores.Length; x++) { // just adding score to string
highScores[x].text = highScoreValues[x].ToString();
}
}
Hey guys. How can I remove duplicates from ScoreBoard array? Tried myself to put this code below the sorting loop but actually nothing happens. I've also tried other methods but they don't work properly. Any help is appreciated.
/*for (int j = 1; j < x; j++)
{
if (highScoreValues[j] == highScoreValues[x])
break;
else
highScoreValues[x] = finall;
}*/