Search Unity

  1. Unity 2019.1 beta is now available.
    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. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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.