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.
Galaxy_ReportScore(leaderboard_id, score_value, level_id?) //level_id is optional
✨ 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 screenGalaxyClientAPI.Controller.OpenLeaderboard(LeaderboardId:"leaderboard_id"); //Only show scores reported for level "level_id" and include ViewOptionsGalaxyClientAPI.Controller.OpenLeaderboard( LeaderboardId:"leaderboard_id", LevelId:"level_id", Options: ViewOptions);
//Overlay on the screenwindow.galaxy.ShowLeaderboard({ leaderboard_id:'leaderboard_id'});
Every Open call accepts an optional ViewOptions parameter that can be used to customize the view. Here's a ViewOptions example with defaults:
newGalaxySDK.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(newGalaxySDK.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 => { });