Get a range of scores centered around a player from a leaderboard version
To get a range of scores centered around a player from an archived leaderboard, use the GetVersionPlayerRangeAsync
method:
public async void GetVersionPlayerRange(string leaderboardId, string versionId)
{
// Returns a total of 11 entries (the given player plus 5 on either side)
var rangeLimit = 5;
var scoresResponse = await LeaderboardsService.Instance.GetVersionPlayerRangeAsync(
leaderboardId,
versionId,
new GetVersionPlayerRangeOptions{ RangeLimit = rangeLimit }
);
Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}
Metadata is not retrieved by default.
To get the score with any associated metadata, use the IncludeMetadata
option on the GetVersionPlayerRangeOptions
configuration object:
public async void GetVersionPlayerRangeWithMetadata(string leaderboardId, string versionId)
{
var scoresResponse = await LeaderboardsService.Instance
.GetVersionPlayerRangeAsync(
leaderboardId,
versionId,
new GetVersionPlayerRangeOptions { IncludeMetadata = true }
);
Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}
For details on how to get available leaderboard version IDs, visit Get available leaderboard version.
For methods that retrieve scores: if your player has not submitted a score and the leaderboard is bucketed, the player is not assigned a bucket. A failed score retrieval returns an error that has its Reason
field set to ScoreSubmissionRequired
.