Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity - Google Play Services - Leaderboard UI crashing

Discussion in 'Scripting' started by PitrasCz, Jul 14, 2018.

  1. PitrasCz

    PitrasCz

    Joined:
    Mar 4, 2016
    Posts:
    26
    Hello. I have a problem with Google Play Services - Leaderboard. Play Services works fine, but when a score is added to Leaderboard, Leaderboard UI is autmatic closed. This problem occurs both in the test and in the official versions of the game. Google Play Console will record the error, but without details.

    Code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using GooglePlayGames;
    5. using GooglePlayGames.BasicApi;
    6.  
    7. public class LeaderboardScript : MonoBehaviour
    8. {
    9.    
    10.     void Start ()
    11.     {
    12.         PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
    13.         PlayGamesPlatform.InitializeInstance(config);
    14.  
    15.         PlayGamesPlatform.Activate();
    16.         SignIn();
    17.     }
    18.  
    19.     void SignIn()
    20.     {
    21.         Social.localUser.Authenticate(success => { });
    22.     }
    23.    
    24.  
    25.     public void LeaderboardButton()
    26.     {
    27.         if(Social.localUser.authenticated)
    28.         {
    29.             PlayGamesPlatform.Instance.ShowLeaderboardUI();
    30.         }
    31.         else
    32.         {
    33.             SignIn();
    34.         }
    35.     }
    36.  
    37.     public void AddScoreToLeaderboard(long score)
    38.     {
    39.         Social.ReportScore(score, GPGSIds.leaderboard_highscore, success => { });
    40.     }
    41. }
    42.  


    Thanks a lot
     
    Last edited: Jul 14, 2018
  2. PitrasCz

    PitrasCz

    Joined:
    Mar 4, 2016
    Posts:
    26
    Btw. I use Google Play Services 0.9.38. Versions larger than 0.9.38 dont work at all.