Playgama
  • Welcome
  • 🚀Quick start
  • Submitting a game
  • Game Requirments
    • 💥Self-check
    • Technical Requirements
    • Advertising Requirements
    • User Experience Requirements
    • Content Requirements
    • Other Requirements
    • Platform-Specific Requirements
  • In-Game Purchases
    • Step-by-step IAP integration guide for Unity
  • FAQ
    • General
    • Submitting a Game
    • Game Moderation
    • Payments and Statistics
  • SDK
    • Getting started
    • Engines
      • Core (Plain JS)
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Unity
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Construct 3
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • GDevelop
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Godot
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Game Maker
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Defold
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
    • Changelog
  • For Partners
    • Getting Started
    • Embed the Widget
      • Adding Games Widget to Your WordPress Site
      • Adding Games Widget to Your Tilda Site
      • Adding Games Widget to Your Framer Site
    • Import the Game Catalog
    • Share your referral link
Powered by GitBook
On this page
  1. SDK
  2. Engines
  3. Unity

Leaderboards

Enhance competitiveness by integrating leaderboards, allowing players to compare their scores and achievements.

Support

Use this to determine if you can implement leaderboards for your game on the current platform.

Check if the leaderboard feature is supported on the platform.

Bridge.leaderboard.isSupported

Check if built-in popup is supported.

Bridge.leaderboard.isNativePopupSupported

Check if multiple boards are supported.

Bridge.leaderboard.isMultipleBoardsSupported

Check if user can set score to leaderboard.

Bridge.leaderboard.isSetScoreSupported

Check if user can retrieve their score.

Bridge.leaderboard.isGetScoreSupported

Check if user can access leaderboard entries including other players' scores.

Bridge.leaderboard.isGetEntriesSupported

Player Scores. Set

Submit the player's score to the leaderboard to update their rank and position.

private void Start()
{
    var options = new Dictionary<string, object>();

    switch (Bridge.platform.id)
    {
        case "yandex":
            options.Add("score", 42);
            options.Add("leaderboardName", "YOUR_LEADERBOARD_NAME");
            break;
        case "facebook":
            options.Add("score", 42);
            options.Add("leaderboardName", "YOUR_LEADERBOARD_NAME");
            break;
        case "msn":
            options.Add("score", 42);
            break;
        case "lagged":
            options.Add("score", 42);
            options.Add("boardId", "YOUR_LEADERBOARD_ID");
            break;
        case "y8":
            options.Add("points", 42);
            options.Add("table", "YOUR_LEADERBOARD_NAME");
            break;
    }

    Bridge.leaderboard.SetScore(options, OnSetScoreCompleted);
}

private void OnSetScoreCompleted(bool success)
{
    if (success)
    {
        // Operation succeeded
    }
    else
    {
        // An error occurred
    }
}

Player Scores. Get

Retrieve the player's score from the leaderboard to display their current standing.

private void Start()
{
    var options = new Dictionary<string, object>();

    switch (Bridge.platform.id)
    {
        case "yandex":
            options.Add("leaderboardName", "YOUR_LEADERBOARD_NAME");
            break;
        case "facebook":
            options.Add("leaderboardName", "YOUR_LEADERBOARD_NAME");
            break;
        case "y8":
            options.Add("table", "YOUR_LEADERBOARD_NAME");
            break;
    }

    Bridge.leaderboard.GetScore(options, OnGetScoreCompleted);
}

private void OnGetScoreCompleted(bool success, int score)
{
    if (success)
    {
        // Data successfully retrieved
        Debug.Log(score);
    }
    else
    {
        // Something went wrong
    }
}

Get Full Leaderboard

Retrieve entries from the leaderboard, including the player's rank and score, to display a comprehensive leaderboard.

Don't call SDK methods that require a callback (like Bridge.leaderboard.GetEntries) when starting the game in Awake. Call them in Start.

private void Start()
{
    var options = new Dictionary<string, object>();

    switch (Bridge.platform.id)
    {
        case "yandex":
            options.Add("leaderboardName", "YOUR_LEADERBOARD_NAME");
            options.Add("includeUser", false); // default = false
            options.Add("quantityAround", 10); // default = 5
            options.Add("quantityTop", 10); // default = 5
            break;
        case "facebook":
            options.Add("leaderboardName", "YOUR_LEADERBOARD_NAME");
            options.Add("count", 10); // default = 5
            options.Add("offset", 0); // default = 0
            break;
        case "y8":
            options.Add("table", "YOUR_LEADERBOARD_NAME");
            options.Add("page", 1); // optional, default = 1
            options.Add("perPage", 10); // optional, default = 20, max = 100
            options.Add("mode", "alltime"); // optional, "alltime" | "last30days" | "last7days" | "today" | "newest"
            break;
    }

    Bridge.leaderboard.GetEntries(options, OnGetEntriesCompleted);
}

private void OnGetEntriesCompleted(bool success, List<Dictionary<string, string>> entries)
{
    Debug.Log($"OnGetEntriesCompleted, success: {success}, entries:");
    
    if (success)
    {
        switch (Bridge.platform.id)
        {
            case "yandex":
                foreach (var entry in entries)
                {
                    Debug.Log("ID: " + entry["id"]);
                    Debug.Log("Score: " + entry["score"]);
                    Debug.Log("Rank: " + entry["rank"]);
                    Debug.Log("Name: " + entry["name"]);
                    Debug.Log("Photo: " + entry["photo"]);
                }
                break;
            case "facebook":
                foreach (var entry in entries)
                {
                    Debug.Log("ID: " + entry["playerId"]);
                    Debug.Log("Score: " + entry["score"]);
                    Debug.Log("Rank: " + entry["rank"]);
                    Debug.Log("Name: " + entry["playerName"]);
                    Debug.Log("Photo: " + entry["playerPhoto"]);
                }
                break;
            case "y8":
                foreach (var entry in entries)
                {
                    Debug.Log("ID: " + entry["playerid"]);
                    Debug.Log("Score: " + entry["points"]);
                    Debug.Log("Rank: " + entry["rank"]);
                    Debug.Log("Name: " + entry["playername"]);
                }
                break;
        }
    }
}

Show Native Popup

Shows leaderboard entries built-in popup

private void Start()
{
    var options = new Dictionary<string, object>();

    switch (Bridge.platform.id)
    {
        case "y8":
            options.Add("table", "YOUR_LEADERBOARD_NAME");
            break;
    }

    Bridge.leaderboard.ShowNativePopup(options, OnShowNativePopupCompleted);
}

private void OnShowNativePopupCompleted(bool success)
{
    if (success)
    {
        // Data successfully retrieved
        Debug.Log(score);
    }
    else
    {
        // Something went wrong
    }
}
PreviousSocial InteractionsNextAchievements

Last updated 19 days ago