- Home /
Does Social.LoadScores report ALL scores on GameCenter?
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!
Answer by CanNguyen · Jul 21, 2018 at 12:24 AM
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.
This appears to still be correct as of 10/28/2020. I'm not sure why you are limited, as in Xcode Game Center allowed you to call more scores (I believe it was 100).
This worked for me, although I added:
leaderboard.timeScope = TimeScope.AllTime;
Before leaderboard.LoadScores to get all time. I was receiving 0 results when I didn't set that, so I'm assu$$anonymous$$g it was defaulting to something else (like today maybe?)
Your answer
Follow this Question
Related Questions
GameCenter How to Track Score? 1 Answer
How do I detect if the player returns from the GameCenter UI? 0 Answers
[Android] GameCenter Social.localUser id uniqueness 0 Answers
Game Center login issue 0 Answers
Is it possible to send Game Center challenges to your friends using Unity's own Social API? 0 Answers