playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.47k stars 966 forks source link

Play Games dont show login, leaderboards and achievements windows in application #2286

Open EGVA opened 6 years ago

EGVA commented 6 years ago

`` using GooglePlayGames; using GooglePlayGames.BasicApi; using UnityEngine; using UnityEngine.SocialPlatforms;

public class PlayGamesScript : MonoBehaviour {

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()    
  .Build();

private void Start()
{
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();

    PlayGamesPlatform.InitializeInstance(config);
    // recommended for debugging:
    PlayGamesPlatform.DebugLogEnabled = true;
    // Activate the Google Play Games platform
    PlayGamesPlatform.Activate(); 
    SignIn() ;
}    
public void SignIn() 
{
    // authenticate user:
    Social.localUser.Authenticate((bool success) =>
    {
        // handle success or failure
        if (success)
            Debug.Log("Conectado");
        else
            Debug.Log("Erro ao conectar");
    });
}
#region Achievements
public static void UnlockAchievement(string id)
{
    if (PlayGamesPlatform.Instance.localUser.authenticated)
        Social.ReportProgress(id, 100, success => { });
}

public static void IncrementAchievement(string id, int stepsToIncrement)
{
    if (PlayGamesPlatform.Instance.localUser.authenticated)
        PlayGamesPlatform.Instance.IncrementAchievement(id, stepsToIncrement, success => { });
}

public static void ShowAchievementsUI()
{
    if (PlayGamesPlatform.Instance.localUser.authenticated)
    {
        PlayGamesPlatform.Instance.ShowAchievementsUI();
    }
}
#endregion /Achievements

#region Leaderboards
public static void AddScoreToLeaderboard(string leaderboardId, long score)
{
    if (PlayGamesPlatform.Instance.localUser.authenticated)
        Social.ReportScore(score, leaderboardId, success => { });
}

public static void ShowLeaderboardsUI()
{
    if (PlayGamesPlatform.Instance.localUser.authenticated)
        Social.ShowLeaderboardUI();
}
#endregion /Leaderboards

} ``

could someone help me solve the problem.

exzizt commented 6 years ago

Learn how to use "adb logcat -s Unity" command and paste the various output it gives here when you try to show the leaderboard, etc.

Edit: On a second look I noticed that you haven't configured your Play Games Configuration properly. Perhaps you should peruse the documentation a little more closely here and also make sure you have followed the documentation in this repos README. If you look at the documentation you will see what you've missed.