Search code examples
androidunity-game-enginegoogle-playleaderboard

Show Leaderboard Score Directly - Google Play Service


I want to show leaderboard score directly as player press on leaderboard icon as like this:

enter image description here

When I was showing a leaderboard it just displaying, list of leaderboard. I want to see actual score directly.

enter image description here

Here is my code:

public void ShowLeaderboard ()
 {
     if (Social.localUser.authenticated)
         Social.ShowLeaderboardUI ();
     else {
         // authenticate user:
         Social.localUser.Authenticate ((bool success) => {
             // handle success or failure
             if (success) {
                 Debug.Log ("Login Success....");
                 PostHighScoreOnLeaderBoard();
                 Social.ShowLeaderboardUI ();
             } else {
                 Debug.Log ("Login Failed....");
             }
         });
     }
 }

How can I show directly a players score?


Solution

  • If you would like the show the user's score directly like in your first image, you need to call PlayGamesPlatform.Instance.ShowLeaderboardUI("leaderboard_id") with the leaderboard ID passed in instead of Social.ShowLeaderboardUI().