Get scores
Retrieve a list of scores from a leaderboard.
Read time 1 minuteLast updated 8 months ago
Players can get the scores from a specified leaderboard with the method. You should create your leaderboard first and then substitute the for your own ID. By default the method will fetch the top 10 scores:
GetScoresAsyncleaderboardIdpublic async void GetScores(string leaderboardId){ var scoresResponse = await LeaderboardsService.Instance .GetScoresAsync(leaderboardId); Debug.Log(JsonConvert.SerializeObject(scoresResponse));}
Paginated access to all scores is available by specifying the optional object with the optional and pagination arguments.
is the number of entries to skip when retrieving the leaderboard scores and defaults to 0.
is the number of leaderboard scores to return and defaults to 10.
GetScoresOptionsOffsetLimitOffsetLimitpublic async void GetPaginatedScores(string leaderboardId){ var scoresResponse = await LeaderboardsService.Instance.GetScoresAsync( leaderboardId, new GetScoresOptions{ Offset = 25, Limit = 50 } ); Debug.Log(JsonConvert.SerializeObject(scoresResponse));}
To get the score with any associated metadata, use the option on the configuration object:
IncludeMetadataGetScoresOptionspublic async void GetScoresWithMetadata(string leaderboardId){ var scoreResponse = await LeaderboardsService.Instance .GetScoresAsync( leaderboardId, new GetScoresOptions { IncludeMetadata = true } ); Debug.Log(JsonConvert.SerializeObject(scoreResponse));}
For details on how to get available leaderboard version IDs, visit Get available leaderboard version.