Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Ronggowisnu · Aug 10, 2014 at 03:44 PM · leaderboard

How to get the user score value from Google Play Services Leaderboard?

I know this is the basic of posting the score :

 Social.ReportScore(TheScore, "LeaderboardID", (bool success) => {
         // handle success or failure
         });


But how do I "get" the score to be displayed again within the game? the problem is that whenever I update my app on Play Store, the local score returns to "0", but the ones on the Google Play Service Leaderboard is still intact, so I am looking for a way to get that Leaderboard value back to the game.

thx :)

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TotalPixel · Aug 11, 2014 at 04:20 PM 1
Share

Am also interested in an answer to this.

avatar image Phuzz · Feb 26, 2015 at 01:59 PM 0
Share

Hello,

Any updates to this? I used to be able to Get Score using Android Native Plugin, but there must be a way that works without it.

avatar image meat5000 ♦ · Feb 26, 2015 at 02:01 PM 0
Share

Why does everyone seem to use a plugin for this?

Its all explained on the second page of the First Google Dev tutorial.

avatar image hurlbz · Feb 27, 2015 at 01:19 AM 1
Share

1.5k people have viewed this post. Still no answers.. this does not look promising. If anyone knows the answer please post (ideally without necessitating use of native code). This is pretty big feature to be missing from play services since you can't keep the game properly in sync.

avatar image thexdd · Apr 30, 2015 at 07:55 AM 0
Share

Is there someone who did this already? Seems like they have implemented this feature, haven't they?

9 Replies

· Add your reply
  • Sort: 
avatar image
12

Answer by Virdari · Oct 15, 2015 at 11:24 AM

For those of you who are trying to get the leaderboard score from Google Play try this code after you're authenticated:

  PlayGamesPlatform.Instance.LoadScores (
             <your_leaderboard_ID_here>,
             LeaderboardStart.PlayerCentered,
             1,
             LeaderboardCollection.Public,
             LeaderboardTimeSpan.AllTime,
         (LeaderboardScoreData data) => {
             Debug.Log (data.Valid);
             Debug.Log (data.Id);
             Debug.Log (data.PlayerScore);
             Debug.Log (data.PlayerScore.userID);
             Debug.Log (data.PlayerScore.formattedValue);
         });
     }

Basically, data.PlayerScore.UserID will give you the player's unique ID, data.PlayerScore.formattedValue will give you the highest score of the player that was submitted to the Google Play leaderboards. data.Id will give you the leaderboard ID and so on.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image alonsoch · Jan 08, 2016 at 09:31 PM 0
Share

The retieved value from "data.PlayerScore.value" is always 0... im trying this code:

 public void UpdateCoin$$anonymous$$erBoard(int coinsCollected){
          $$anonymous$$erboardScoreData data = new $$anonymous$$erboardScoreData (leaderboard_coin_collector);
          long retrievedScore = data.PlayerScore.value;
          long total = retrievedScore +(long)coinsCollected;
          Social.ReportScore(total,leaderboard_coin_collector, (bool success) => {  });
  }

I need to get the current coins and then increment that value.... but "retrievedScore" is always 0

avatar image Goodie848 · Apr 20, 2016 at 10:53 AM 0
Share

Thanks Virdari, it works like a charm.

avatar image Munchy2007 · May 12, 2016 at 10:48 AM 0
Share

This method works, and allows you to retrieve the local user score without having to display the built in leaderboard, useful for displaying the current high score on your in game UI.

You will need to add the following using statements for it to work as posted though.

         using GooglePlayGames;
         using GooglePlayGames.BasicApi;


avatar image WILEz1975 · Aug 09, 2017 at 07:48 PM 0
Share

I need help in getting the player nickname (like Bob, Andrew, Christopher) of the player in the leaderboard of my game. When I use loadScores, I only get the playerID( which is a string numbers), I tried to use loadPlayers and use alias, it doesn't give me anything. I can successfully logged in in google play game services. Like:

  //1
  FirstNickName.text = data.Scores[0].userID;
  //2
  SecondNickName.text = data.Scores[1].userID;
  //3
  ThirdNickName.text = data.Scores[2].userID;

etc...

avatar image ArbreCasual · May 10, 2018 at 09:17 AM 0
Share

Thank You @virdari :)

avatar image
1

Answer by meat5000 · Apr 20, 2016 at 11:12 AM

Seriously, this is not a Unity question, its a Google one.

The STARTING page of the Google Dev quickstart deals with Achievements and leaderboards.

https://developers.google.com/games/services/android/quickstart

Do the sample project. It will take half an hour. By the end of it you will know how leaderboards work and how to use them in your project.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Coder Gogoi · Aug 14, 2014 at 08:05 AM

You have to call Leader biard display methodt o get the Leader board score on your game.

  1. Set up you leader biard on Google Play Game Service. just go through. https://developers.google.com/games/services/common/concepts/leaderboards

  2. Use the Google play Plugins : https://github.com/playgameservices/play-games-plugin-for-unity

You can use the following method to call leader board. It is working in my case.

 using UnityEngine;
 using System.Collections;
 using GooglePlayGames;
 using UnityEngine.SocialPlatforms;
 
 public class _GameCenterManager : MonoBehaviour {
       
     // Use this for initialization
     void Start () {
 
         
         AuthonicatePlayer();
 
     }
 
 
     private void AuthonicatePlayer(){
 
         PlayGamesPlatform.DebugLogEnabled = true;
         PlayGamesPlatform.Activate();
         
         Social.Active.localUser.Authenticate(ProcessAuthentiation);
         Debug.Log("Login Process ...");
 
     }
 
 
 
     // Call this method on Show Achievement Button action 
 
     public void GC_ReportAchievementScore(){
 
  
         if(PlayerPrefs.GetInt ("Hero")> 0){
 
             SubmitAchievementProgress("Achievement ID Here");
         }
         Social.ShowAchievementsUI();
         
     }
 
 
     void SubmitAchievementProgress(string MyID){
 
         Social.ReportProgress(MyID, 100.0f, (bool success) => {
             
             
             if(success){
                 
                 print("successfully reported Achievement");
             }else{
                 
                 print("Something... wrong on report score");
             }
         } );
     }
 
      
     // Call this method on Show Leaderboard Button action 
 
 
     public void GC_ReportHighScore(){
 
             
         long currentScore = PlayerPrefs.GetInt ("TotalScore");
         Social.ReportScore(currentScore, "Your Leader Board ID", (bool success) => {
             // handle success or failure
             
             if(success){
                 
                 print ("successfully reported");
 
             }else{
                 
                 print("Something... wrong on report score");
             }
         } );
 
         ((PlayGamesPlatform) Social.Active).ShowLeaderboardUI("Your Leader Board ID");
 
 
     }
  
     
     // Update is called once per frame
     void Update () {
     }
 
     void ProcessAuthentiation(bool success)
     {
         if (success)
         {
             print("successfully authonicated");
         }
         else
         {
             print("fail to authonicate");
         }
     }
 
 }
 

 

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ronggowisnu · Aug 14, 2014 at 08:21 AM 0
Share

Hey ! thx for your idea :) but I have already done all those steps including the script. What I am looking for is a way to load/sync the user's highest score on Google leaderboard with the local score. The idea is to keep the score even when the user has uninstalled the app, that way when the user install it again, he/she will keep the highest score (not 0 again).

I am also thinking about cloud save state on that plugin, but I am stuck as well.

here is the current app btw : link text

avatar image achillesdotexe · Jun 22, 2015 at 12:02 AM 0
Share

Sorry bringing this up now. I am into the same situation now, couldn't find any solution. Please share if you have fixed this.

avatar image
0

Answer by taxvi · Feb 19, 2015 at 11:08 AM

I'm having the same problem, unfortunately the plugin says this functionality is not supported yet :( alt text

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image taxvi · Feb 27, 2015 at 06:28 AM 0
Share

the same goes with plenty other functions like LoadFriends and LoadUsers, etc. Check the pop-up comments like in the pic before using the methods.

avatar image taxvi · Feb 27, 2015 at 06:51 AM 0
Share

and yes, @meat5000 is right, writing your own plugin is much less pain (and makes you feel more powerful, muahahahaa...)

avatar image achillesdotexe · Jun 19, 2015 at 02:07 PM 0
Share

I am into the same situation now. Any one found a work around?

avatar image achillesdotexe · Jun 21, 2015 at 11:59 PM 0
Share

any one got a solution for this? please share.

avatar image Phuzz · Jun 22, 2015 at 06:15 AM 0
Share

Nothing yet, the command is there but its not yet implemented, I dont know when it will be, I am just sing Android Native Plugin since its the only solution I know of so far.

avatar image
0

Answer by wuym67123 · Jan 03, 2017 at 08:28 AM

public void loadTopLeaderboardScores(string leaderboardId, int span, int leaderboardCollection, int maxResults,bool forceReload)

Asynchronously load the top page of scores for a given leaderboard.

https://github.com/unity-plugins/google-service-unity/wiki/Unity-Google-Game-API#public-void-loadtopleaderboardscoresstring-leaderboardid-int-span-int-leaderboardcollection-int-maxresultsbool-forcereload

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Google Play Games Plugin(A simple issue) 0 Answers

Cloud recognition in Vuforia 0 Answers

Google Play Services show leaderboard 1 Answer

Play Game Services plugin Save State Issue 0 Answers

GPGS Reporting score/progress doesn't work 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges