Get the player’s score from a Leaderboard version
Players can get their entry in the specified leaderboard archive version with the GetVersionPlayerScoreAsync
method:
public async void GetPlayerVersionScore(string leaderboardId, string versionId)
{
var scoreResponse = await LeaderboardsService.Instance
.GetVersionPlayerScoreAsync(leaderboardId, versionId);
Debug.Log(JsonConvert.SerializeObject(scoreResponse));
}
Metadata is not retrieved by default.
To get the score with any associated metadata, use the IncludeMetadata
option on the GetVersionPlayerScoreOptions
configuration object:
public async void GetPlayerVersionScoreWithMetadata(string leaderboardId, string versionId)
{
var scoreResponse = await LeaderboardsService.Instance
.GetVersionPlayerScoreAsync(
leaderboardId,
versionId,
new GetVersionPlayerScoreOptions { IncludeMetadata = true }
);
Debug.Log(JsonConvert.SerializeObject(scoreResponse));
}
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
.