I have this piece of code tied to Apple’s GameCenter:
Social.LoadScores("HighScore", scores => {
if (scores.Length > 0) {
Debug.Log("HIGHSCORE: " + int.Parse(scores[0].formattedValue));
}
});
I’m wondering why scores is a list of values. I can only test with one user so would scores be a list of ALL scores on GameCenter? I only need the localUser score!
To retrieve local player score, you can get the scores from a specific leaderboard doing something like this:
ILeaderboard leaderboard = Social.CreateLeaderboard();
leaderboard.id = "HighScore";
leaderboard.LoadScores(success =>
{
if (!success)
{
// Handle fail case: this is when your leaderboard doesn't load scores successfully
}
else
{
// you can retrieve the score of local user here
long localUserScore = leaderboard.localUserScore.value;
}
});
To answer you question: Social.LoadScores does get a list of values into scores, and I’m just finding out right now that it seems to only load top 10 scores (I literally just made multiple apple IDs to test).
I know this answer is late, but hopefully it can help whoever that stumbles across this post in the future.