Get scores from a leaderboard version
Retrieve a list of scores from a specific leaderboard.
Read time 1 minuteLast updated 8 months ago
Players can get scores from a specified leaderboard version with the method. By default the method fetches the top 10 scores:
GetVersionScoresAsyncpublic async void GetVersionScores(string leaderboardId, string versionId){ var scoresResponse = await LeaderboardsService.Instance .GetVersionScoresAsync(leaderboardId, versionId); Debug.Log(JsonConvert.SerializeObject(scoresResponse));}
Paginated access to all scores in the leaderboard is available by specifying the optional object with the optional and pagination arguments.
GetVersionScoresOptionsOffsetLimitOffsetLimitpublic async void GetPaginatedVersionScores(string leaderboardId, string versionId){ var scoresResponse = await LeaderboardsService.Instance.GetVersionScoresAsync( leaderboardId, versionId, new GetVersionScoresOptions{ Offset = 25, Limit = 50 } ); Debug.Log(JsonConvert.SerializeObject(scoresResponse));}
To get the score with any associated metadata, use the option in the configuration object:
IncludeMetadataGetVersionScoresOptionspublic async void GetVersionScoresWithMetadata(string leaderboardId, string versionId){ var scoresResponse = await LeaderboardsService.Instance.GetVersionScoresAsync( leaderboardId, versionId, new GetVersionScoresOptions { IncludeMetadata = true } ); Debug.Log(JsonConvert.SerializeObject(scoresResponse));}
For details on how to get available leaderboard version IDs, see Get available leaderboard version.