Leaderboard
API References for Leaderboard Service
Explore the list of API functions available in Unity for managing leaderboards and player scores, including detailed descriptions and usage examples.
To use services functions, first ensure that the service is activated before. You can see services by opening "Service Hub" From game's dashboard header.
Get Available Leaderboards
Retrieves a list of leaderboards based on the provided parameters.
var leaderboards = await ServiceHub.Services.Leaderboard.GetLeaderboards(new GetLeaderboardsParams
{
label = null,
skip = 0,
limit = 0
});
Get Users Scores
Obtains scores for individual users as specified by the input parameters.
var scores = await ServiceHub.Services.Leaderboard.GetUsersScores<GetScoresParams, UserScore>(new GetScoresParams
{
Leaderboardid = 0,
skip = 0,
limit = 0,
returnUserScore = false,
Conditions = new Eq("field", "value").ToQuery()
});
Get Parties Scores
Fetches scores for different parties (e.g., teams or groups) according to the given parameters.
var scores = await ServiceHub.Services.Leaderboard.GetPartiesScores<GetScoresParams, PartyScore>(new GetScoresParams
{
Leaderboardid = 0,
skip = 0,
limit = 0,
returnUserScore = false,
Conditions = new Eq("field", "value").ToQuery()
});
Get Friends Scores
Gathers scores specifically for friends of the current user.
var scores = await ServiceHub.Services.Leaderboard.GetFriendsScores(new GetFriendsScoresParams
{
LeaderboardId = 0,
Skip = 0,
Limit = 0
});
Get My Score
Retrieves the score of the current user based on the input parameters.
var score = await ServiceHub.Services.Leaderboard.GetMyScore<GetCurrentUserScoreParams, UserScore>(new GetCurrentUserScoreParams
{
LeaderboardId = 0,
Conditions = new Eq("field", "value").ToQuery()
});
Submit New Score
Submits a user's score and returns the result.
var score = await ServiceHub.Services.Leaderboard.SubmitScore<SubmitScoreParams, UserScore>(
new SubmitScoreParams
{
LeaderboardId = 0,
Score = 0,
OtherData = new Dictionary<string, dynamic>(),
PartyId = 0,
UniqueBy = "extended_field"
});
Last updated