文档

支持

Get scores from a leaderboard version

Retrieve a list of scores from a specific leaderboard.
阅读时间1 分钟最后更新于 1 个月前

Players can get scores from a specified leaderboard version with the
GetVersionScoresAsync
method. By default the method fetches the top 10 scores:
public 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
GetVersionScoresOptions
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 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
IncludeMetadata
option in the
GetVersionScoresOptions
configuration object:
public 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.