Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by DroidifyDevs · Feb 07, 2016 at 12:53 AM · c#scripting problemgoogle play gamesleaderboardsreport

Why isn't this script posting the score to Google Play Leaderboards?

Hi there!

I made this script to post the score to my leaderboard, but for some reason the leaderboard UI opens but it says "No one in your circles has played (my project)". Why isn't the score posting?

 using UnityEngine;
  using System.Collections;
  using GooglePlayGames;
  using UnityEngine.SocialPlatforms;
  
  public class PlayGames: MonoBehaviour {
        
      // Use this for initialization
      void Start () 
     {
         Social.localUser.Authenticate((bool success) => {
         // handle success or failure
     }); 
         Social.ReportScore (54321, "CgXXXX3m-XXXXAI", (bool success) => {
 
         });
         Social.ShowLeaderboardUI();
         }
  }

Leaderboard ID partially hidden (so no one posts fake scores). Thank you so much!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DroidifyDevs · Feb 09, 2016 at 02:28 AM

YES, I FINALLY GOT IT

This is what I did, I'm sure some of this is redundant: 1: When to the Google Developer console and loaded up my APK as a Beta game 2: Went into the Google Developer console > Google services and created all new leaderboards. 3: Changed my game's package name (com.DroidifyDevs.RocketTest) 4: Reinstalled Google Play pugin 5: Used this script:

 using GooglePlayGames;
 using UnityEngine;
 using System.Collections;
 
 
 public class PlayGamesWorksinRT2 : MonoBehaviour {
 
     // Use this for initialization
     void Start() {
         PlayGamesPlatform.Activate();
         Social.localUser.Authenticate((bool success) =>
         {
             if (success)
             {
                 GoogleTest();
                 PlayGamesPlatform.Activate();
                 Social.ShowLeaderboardUI();
             }
             else
                 Debug.Log("Auth wrong :(");
         });
 
         PlayGamesPlatform.Activate();
         Social.ReportScore(50, "CgxxxxxxxxxxxBQ", (bool success) => {
 
         });
         
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     void GoogleTest() //Call GameOver whenever your game is... over, let say .. when your player got N amount of points or N amount of damage...
     {
         //if (actualScore >= 5000)
         //    winText.text = "Good Job";
 
         Debug.Log("Activated, Auth begins");
         PlayGamesPlatform.Activate();
         Social.ReportScore(50, "CgXXXXXXXXXXBQ", (bool success) => {
 
         });
         PlayGamesPlatform.Activate();
         Social.ShowLeaderboardUI();
     }
 }

So basically I reset anything that could be reset. Feeling damn proud of myself :)

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 farhan3d · Nov 27, 2016 at 05:55 AM 0
Share

Good for you, but I'm still struggling with the same problem and can't really figure out what the actual cause is. Were you able to deter$$anonymous$$e the exact thing that was causing the problem? Would appreciate some help. Thx! :)

avatar image dandepeched · Aug 01, 2017 at 03:53 PM 0
Share

"You should only call PlayGamesPlatform.Activate once in your application." https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/READ$$anonymous$$$$anonymous$$md

avatar image
0

Answer by corn · Feb 07, 2016 at 11:06 AM

You need to initialize PlayGamesPlatform before authenticating.

 GooglePlayGames.PlayGamesPlatform.Activate();
 Social.localUser.Authenticate((bool success) => {
      Debug.LogFormat("Authentication success : {0}", success);
  }); 
Comment
Add comment · Show 4 · 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 DroidifyDevs · Feb 07, 2016 at 01:59 PM 0
Share

@corn Thanks for the hep. Unfortunately it opens the leaderboard but doesn't post any score at all. Here's the updated script:

 using UnityEngine;
  using System.Collections;
  using GooglePlayGames;
  using UnityEngine.SocialPlatforms;
  
  public class PlayGames: $$anonymous$$onoBehaviour {
        
      // Use this for initialization
      void Start () 
     {
         GooglePlayGames.PlayGamesPlatform.Activate ();
         Social.localUser.Authenticate((bool success) => {
         // handle success or failure
         }); 
         Social.ReportScore (54321, "CXXXXXm-mXXXXXI", (bool success) => {
         });
         Social.Show$$anonymous$$erboardUI();
         }
 }

I've even created other leaderboards but to no avail.

avatar image corn DroidifyDevs · Feb 07, 2016 at 03:52 PM 0
Share

@putin2001 That's because Authenticate and ReportScore are asynchronous, they need callbacks. In your program, Social.ReportScore is executed before the authentication result is even received, it can't work.

Just report the score after authentication has succeeded.

 void Start()
     {
         GooglePlayGames.PlayGamesPlatform.Activate();
         Social.localUser.Authenticate((bool success) =>
         {
             if (success)
             {
                 Social.ReportScore(54321, "CXXXXXm-mXXXXXI", (bool reportScoreSuccess) =>
                 {
                     if (reportScoreSuccess)
                     {
                         Social.Show$$anonymous$$erboardUI();
                     }
                     else
                     {
                         Debug.Log("Score reporting failure");
                     }
                 });
             }
             else
             {
                 Debug.Log("Authentication failure");
             }
         });
     }

Now that's just a quick fix. It'd be much more convenient for your tests to have a public ReportScore function that'd you call with a GUI button.

avatar image DroidifyDevs corn · Feb 08, 2016 at 10:52 PM 0
Share

@corn I tried that script, still no avail. Do I need to have the google play services linked properly to the latest AP$$anonymous$$ of my app? I guess I'll find out in a few hours as I'm waiting for Google to finish processing my changes. What is wierd is the script shows "Google play Games" then asks me what account to use, then asks if I agree with the app's use of my info, then that's it, it doesn't even show the log-in icon on the top of the screen (which normally would show up and show your account picture along with gamer level). So I'm thinking that it isn't properly logging in. In a previous project I actually got the leaderboards to work with this script:

 using GooglePlayGames;
 using UnityEngine;
 using System.Collections;
 
 
 public class PlayGamesWorksinRT2 : $$anonymous$$onoBehaviour {
 
     // Use this for initialization
     void Start() {
         PlayGamesPlatform.Activate();
         Social.localUser.Authenticate((bool success) =>
         {
             if (success)
             {
                 GoogleTest();
                 PlayGamesPlatform.Activate();
                 Social.Show$$anonymous$$erboardUI();
             }
             else
                 Debug.Log("Auth wrong :(");
         });
         
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     void GoogleTest() //Call GameOver whenever your game is... over
     {
         //if (actualScore >= 5000)
         //    winText.text = "Good Job";
 
         Debug.Log("Activated, Auth begins");
 
         Social.ReportScore(50000, "CXXXXXXXXXXXXXXXXQ", (bool success) => {
 
         });
         PlayGamesPlatform.Activate();
         Social.Show$$anonymous$$erboardUI();
     }
 }

So I don't see what I'm doing wrong now as I've done this before...

Show more comments

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

88 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 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 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 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 Services leaderboard not updating after high score is beaten? 1 Answer

Finding the max Y position value in a list of game objects and assigning it to a variable? 0 Answers

Running C# Function from JS file 0 Answers

i need help with my board manager coding ASAP 1 Answer

Hololens sharing example 1 Answer


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