Documentation

Support

Get scores

Retrieve a list of scores from a leaderboard.
Read time 1 minuteLast updated 21 days ago

Players can get the scores from a specified leaderboard with the
GetScoresAsync
method. You should create your leaderboard first and then substitute the
leaderboardId
for your own ID. By default the method will fetch the top 10 scores:
public 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
GetScoresOptions
object with the optional
Offset
and
Limit
pagination arguments.
Offset
is the number of entries to skip when retrieving the leaderboard scores and defaults to 0.
Limit
is the number of leaderboard scores to return and defaults to 10.
public 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
IncludeMetadata
option on the
GetScoresOptions
configuration object:
public 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.