How to get Leaderbo...
 
Notifications
Clear all

How to get Leaderboard count?

3 Posts
2 Users
0 Reactions
839 Views
(@dustin1138)
Posts: 21
Eminent Member
Topic starter
 

Is there a way to read the number of records in the leaderboard table? Right now I'm loading in batches of 10 since any more than that seems to take a long time (around a half a second per record it seems, on average). I'd like to have a "jump to the bottom of the list" button but I have no way of knowing what that is without guessing or stepping through chunks until the returned records are less than the requested range. I guess that I'm asking for something like this:

Leaderboard leaderboard;

...

int totalCount = leaderboard.length;

 

Or something similar. Thanks!

 
Posted : 05/02/2019 10:58 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

You can instantiate a Leaderboard object and read its maxRange property as pages count in the callback of LoadScores, for example:

Leaderboard leaderboard = new Leaderboard();
leaderboard.id = leaderboardID;
leaderboard.timeScope = TimeScope.AllTime;
leaderboard.range = new Range(page, countPerPage);
leaderboard.LoadScores((bool success) => {
    if (success)
        Debug.Log("Results in this page: " + leaderboard.scores.Length + " - Number of pages: " + leaderboard.maxRange);
});

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 06/02/2019 10:55 am
(@dustin1138)
Posts: 21
Eminent Member
Topic starter
 

Ah, MaxRange. Perfect, thanks!

 
Posted : 06/02/2019 5:35 pm
Share: