You need to create a leaderboard on your dashboard before proceeding. Make sure you set up automatic resets and prizes in the dashboard if needed.

⬆️ Report a score

Report scores from a user. LevelId is optional and can be any string to distinguish your levels. You do not need to individually create leaderboards for each level! Passing a LevelId acts as a filter.

What is a Level? You can use a LevelId if you want separate leaderboards for separate levels in your game, without having to create multiple leaderboards. Just use the same LevelId to report the score and show the leaderboard. This is fully optional.

GalaxyClientAPI.ReportScore(new GalaxySDK.ClientModels.ReportScoreRequest {
    Score = 500.0, //required
    LeaderboardId = "leaderboard_id", //required
    LevelId = "level_id", //optional
}, result => { }, error => { });

Show the leaderboard

Configure the leaderboard UI, reset behavior, and more in your dashboard.

The UI doesn't work in the Unity editor! Run on a real device to test.

//Show a combined UI for the default leaderboard full screen
GalaxyClientAPI.Controller.OpenLeaderboard(LeaderboardId: "leaderboard_id"); 

//Only show scores reported for level "level_id" and include ViewOptions
    LeaderboardId: "leaderboard_id",  
    LevelId: "level_id",
    Options: ViewOptions

Every Open call accepts an optional ViewOptions parameter that can be used to customize the view. Here's a ViewOptions example with defaults:

new GalaxySDK.GalaxyController.ViewOptions {
    Left = 0,
    Top = 0,
    Right = 0,
    Bottom = 0,
    HideCloseButton = false,
    CloseButtonPosition = 0, //0 for left, 1 for right
    OnClose = onClose //Action

⬇️ Get a player's record

A player record contains information about their score/rank on a specific leaderboard. If no PlayerId is passed, the current user is returned.

GalaxyClientAPI.GetPlayerRecord(new GalaxySDK.ClientModels.GetPlayerRecordRequest {
    LeaderboardId = "leaderboard_id", //required
    LevelId = "level_id", //optional
    PlayerId = "player_id" //optional
}, result => { 
    var playerRank = result.Record.Rank;
    var playerScore = result.Record.Score;
}, error => { });
Player Record Objects


/// User records for the requested user.
public LeaderboardRecord Record;

LeaderboardRecord reference

⬇️ Get leaderboard records

Get the leaderboard data directly

GalaxyClientAPI.GetLeaderboard(new GalaxySDK.ClientModels.GetLeaderboardRequest {
    LeaderboardId = "leaderboard_id",
    Offset = 0,
    Limit = 50,
    LevelId = "level_id", //optional
}, result => { 
    var records = result.Records;
}, error => { });
Leaderboard Record Objects


/// User records for the requested user.
public List<LeaderboardRecord> Records;

LeaderboardRecord reference

Last updated