Get scores for other players
Get the scores for other players in the specified leaderboard with the GetScoresByPlayerIdsAsync
method:
C#
public async void GetScoresByPlayerIds()
{
var otherPlayerIds = new List<string>{ "abc123", "abc456" };
var scoresResponse = await LeaderboardsService.Instance
.GetScoresByPlayerIdsAsync(leaderboardId, otherPlayerIds);
Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}
To get the score with any associated metadata, use the IncludeMetadata
option in the GetScoresByPlayerIdsOptions
configuration object:
C#
public async void GetScoresByPlayerIdsWithMetadata()
{
var scoreResponse = await LeaderboardsService.Instance
.GetScoresOptions(
leaderboardId,
new GetScoresByPlayerIdsOptions { 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
.