Get scores for other players
Using GetScoresByPlayerIdsAsync
is not supported on leaderboards with buckets configured.
Get the scores for other players in the specified leaderboard with the GetScoresByPlayerIdsAsync
method:
public async void GetScoresByPlayerIds(string leaderboardId)
{
var playerIds = new List<string>{ "abc123", "abc456" };
var scoresResponse = await LeaderboardsService.Instance
.GetScoresByPlayerIdsAsync(leaderboardId, playerIds);
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 GetScoresByPlayerIdsOptions
configuration object:
public async void GetScoresByPlayerIdsWithMetadata(string leaderboardId)
{
var playerIds = new List<string>{ "abc123", "abc456" };
var scoreResponse = await LeaderboardsService.Instance
.GetScoresByPlayerIdsAsync(
leaderboardId,
playerIds,
new GetScoresByPlayerIdsOptions { IncludeMetadata = true }
);
Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}