Get scores

Players can get the scores from a specified leaderboard with the GetScoresAsync method. You should create your leaderboard first and then substitute the leaderboardId for your own ID. By default the method will fetch the top 10 scores:

C#

public async void GetScores()
{
    var scoresResponse = await LeaderboardsService.Instance
        .GetScoresAsync(leaderboardId);
    Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}

Paginated access to all scores is available by specifying the optional GetScoresOptions object with the optional Offset and Limit pagination arguments. Offsetis the number of entries to skip when retrieving the leaderboard scores and defaults to 0. Limit is the number of leaderboard scores to return and defaults to 10.

C#

public async void GetPaginatedScores()
{
    var scoresResponse = await LeaderboardsService.Instance.GetScoresAsync(
        leaderboardId,
        new GetScoresOptions{ Offset = 25, Limit = 50 }
    );
    Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}

To get the score with any associated metadata, use the IncludeMetadata option in the GetScoresOptions configuration object:

C#

public async void GetScoresWithMetadata()
{
    var scoreResponse = await LeaderboardsService.Instance
        .GetScoresOptions(
            leaderboardId,
            new GetScoresOptions { IncludeMetadata = true });
    Debug.Log(JsonConvert.SerializeObject(scoreResponse));
}

Metadata is not retrieved by default.

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.