Get the player’s score
Get the entry for the player in the specified leaderboard with the GetPlayerScoreAsync
method:
C#
public async void GetPlayerScore()
{
var scoreResponse = await LeaderboardsService.Instance
.GetPlayerScoreAsync(leaderboardId);
Debug.Log(JsonConvert.SerializeObject(scoreResponse));
}
To get the score with any associated metadata, use the IncludeMetadata
option in the GetPlayerScoreOptions
configuration object:
C#
public async void GetPlayerScore()
{
var scoreResponse = await LeaderboardsService.Instance
.GetPlayerScoreAsync(
leaderboardId,
new GetPlayerScoreOptions { IncludeMetadata = true });
Debug.Log(JsonConvert.SerializeObject(scoreResponse));
}
Metadata is not retrieved by default.
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
.