In this section you will learn how to access the leaderboards data and report a score.
Loading Scores
To retrieve the scores list of a leaderboard you can call CombuManager.platform.LoadScores (by default loads the first page with 10 results), or you can instantiate a new Leaderboard object (created with CombuManager.platform.CreateLeaderboard), set timeScope, customTimescope and range and then call LoadScores:
CombuManager.platform.LoadScores(123, 2, 10, (IScore[] scores) => {
Debug.Log("Scores loaded: " + scores.Length);
});
Leaderboard board = CombuManager.platform.CreateLeaderboard();
board.id = "123";
board.timeScope =
UnityEngine.SocialPlatforms.TimeScope.AllTime;
board.range =
new UnityEngine.SocialPlatforms.Range(1, 10);
board.LoadScores((bool loaded) => {
});
Reporting Scores
To report a new score of the local user you need to call CombuManager.platform.ReportScore, or you can call the method ReportScore on a Score instance:
CombuManager.platform.ReportScore(1000, "123", (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
myScore.value = 1000;
myScore.ReportScore( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Loading Leaderboards data
To load the leaderboards data like the title, description etc, you need to call Leaderboard.Load:
Leaderboard.Load("123", (Leaderboard leaderboard, string error) => {
if (success)
Debug.Log("Success: " + leaderboard.title);
else
Debug.Log("Failed: " + error);
});
Loading the score of a user
To retrieve the best score of a user you need to call Leaderboard.LoadScoresByUser:
Leaderboard.LoadScoresByUser(
"123", user,
eLeaderboardInterval.Week, 10, (Score score,
int page,
string error) => {
if (success)
Debug.Log("Success: " + score.value + " at page " + page);
else
Debug.Log("Failed: " + error);
});