play-games-plugin-for-unity icon indicating copy to clipboard operation
play-games-plugin-for-unity copied to clipboard

Google Play Service UI not showing at all

Open KhalidSaud opened this issue 6 years ago • 13 comments

Hello everyone,

I'm trying to figure out if I'm doing the coding wrong or not,

`using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using GooglePlayGames; using UnityEngine.SocialPlatforms; using GooglePlayGames.BasicApi;

public class GameManager : MonoBehaviour {

public Text scoretext;
int score = 0;

// Use this for initialization

void Start () {

}

// Update is called once per frame
void Update()
{

}


void Awake()
{
    DontDestroyOnLoad(transform.gameObject);

    // Google Play Service
     PlayGamesPlatform.Activate();
     OnConnectionResponse(PlayGamesPlatform.Instance.localUser.authenticated);
}


public void add10()
{
    score = score + 10;
    scoretext.text = score.ToString();

    if (score >= 50)
    {
        Debug.Log("50 Coins");
        UnlockAchievement(GPGSIds.achievement_50_coins);
    }
    if (score >= 100)
    {
        Debug.Log("50 Coins");
        UnlockAchievement(GPGSIds.achievement_100_coins);
    }

}

public void AddLeaderboard()
{
    ReportScore(score);
}


public void OnClickSignIn()
{
    Social.localUser.Authenticate((bool success) =>
    {
        OnConnectionResponse(success);
    });
}
private void OnConnectionResponse(bool authunticated)
{
    if (authunticated)
    {
        Debug.Log("Connected");
        scoretext.text = "Connected";
    }
    else
    {
        Debug.Log("Error in connection");
        scoretext.text = "Error in connection";
    }
}


public void OnAchievmentClick()
{
    if (Social.localUser.authenticated)
    {
        Social.ShowAchievementsUI();
    }
}

public void UnlockAchievement(string achievementID)
{
    Social.ReportProgress(achievementID, 100.0f, (bool success) =>
    {
        Debug.Log("Achievemnt Unlocked " + success.ToString());
    });
}

public void OnLeaderboardClick()
{
    if (Social.localUser.authenticated)
    {
        Social.ShowLeaderboardUI();
    }
}

public void ReportScore(int score)
{
    Social.ReportScore(score, GPGSIds.leaderboard_highscore, (bool success) =>
    {
        Debug.Log("Report score to leaderboard " + success.ToString());
    });
}

} `

KhalidSaud avatar Jan 24 '18 18:01 KhalidSaud

Same issue. You'd think they'd test these simple and main uses, but guess not. I'm beginning to think Google does not maintain these plugins as stated on their website.

AnnCoa avatar Feb 01 '18 04:02 AnnCoa

I also have this Issue. I tried almost everything but can not get it to work.

Sonic1305 avatar Feb 01 '18 23:02 Sonic1305

i am using GamesPlayPlatform instance and it's working fine.

if (PlayGamesPlatform.Instance.localUser.authenticated) { PlayGamesPlatform.Instance.ShowLeaderboardUI(); } else { Debug.Log("Cannot show leaderboard: not authenticated"); }

hope it will help.

GhassanF avatar Feb 02 '18 05:02 GhassanF

GhassanF, do you mind showing us your code for logging in and authenticating using PlayGamesPlatform? Also, are you able to report scores and achievements using PlayGamesPlatform?

AnnCoa avatar Feb 02 '18 07:02 AnnCoa

I'm having the same issue. I can send scores to leaderboard and see it on Google Play Games app, but I can't open LeaderboardUI on the game. In logs, callbacks are empty.

ilterbilguven avatar Feb 02 '18 07:02 ilterbilguven

I attached the following script on the main camera in the scene that contains the sign in, show achievements and show leaderboards button

using UnityEngine; using GooglePlayGames.BasicApi; using GooglePlayGames; using UnityEngine.EventSystems; using UnityEngine.UI;

namespace Assets.Scripts { public class GooglePlayGamesManager : MonoBehaviour { public Text SignInButtonText; public Text AuthStatus; public GameObject AchButton; public GameObject LdrButton;

    private void Start()
    {
        // Create client configuration
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();

        // Enable debugging output (recommended)
        PlayGamesPlatform.DebugLogEnabled = true;

        // Initialize and activate the platform
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();

        // Try silent sign-in (second parameter is isSilent)
        PlayGamesPlatform.Instance.Authenticate(SignInCallback, true);

    }

    public void Update()
    {
        AchButton.SetActive(Social.localUser.authenticated);
        LdrButton.SetActive(Social.localUser.authenticated);
    }

    public void SignIn()
    {
        if (!PlayGamesPlatform.Instance.localUser.authenticated)
        {
            // Sign in with Play Game Services, showing the consent dialog
            // by setting the second parameter to isSilent=false.
            PlayGamesPlatform.Instance.Authenticate(SignInCallback, false);
        }
        else
        {
            PlayGamesPlatform.Instance.SignOut();

            SignInButtonText.text = "Sign In";
            AuthStatus.text = "";
        }
    }

    public void SignInCallback(bool success)
    {
        if (success)
        {
            SignInButtonText.text = "Sign out";
            AuthStatus.text = "Signed in as: " + Social.localUser.userName;
        }
        else
        {
            SignInButtonText.text = "Sign in";
            AuthStatus.text = "Sign-in failed";
        }
    }

    public void ShowAchievements()
    {
        if (PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesPlatform.Instance.ShowAchievementsUI();
        }
        else
        {
            Debug.Log("Cannot show Achievements, not logged in");
        }
    }

    public void ShowLeaderboards()
    {
        if (PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesPlatform.Instance.ShowLeaderboardUI();
        }
        else
        {
            Debug.Log("Cannot show leaderboard: not authenticated");
        }
    }
}

}

GhassanF avatar Feb 02 '18 13:02 GhassanF

Tried PlayGamesPlatform.Instance.ShowLeaderboardUI() and Social.ShowAchievementsUI() . They don't work.

ilterbilguven avatar Feb 05 '18 07:02 ilterbilguven

same here. wtf...

zeyangl avatar Mar 06 '18 08:03 zeyangl

Any updates on this?

luisjuniorj avatar Mar 16 '18 00:03 luisjuniorj

My problem was solved. It seemed to be an issue with the postprocess step. The GooglePlayServices.plugin project is not exported to gradle at all, thus my game not having app_id or version strings in xml. I just renamed the folder then renamed it back and it worked. Really weird.

zeyangl avatar Mar 16 '18 02:03 zeyangl

@zeyangl Could you please elaborate?

soham387 avatar May 17 '18 03:05 soham387

I am using the unity play game services plugin 0.9.36 for my game which was published last year and was working correctly. But last week I updated the game and deleted the old leaderboard and added a new one but it won't work. When I open the leader board for the first time with zero highscores it works, but when I make a new highscore , the leaderboard does not open. I am using the following code to display the Leaderboard - public void OnLeaderboardClick() { if (Social.localUser.authenticated) { Social.ShowLeaderboardUI(); } } I am using the following code to report scores to the Leaderboard - public void ReportScore(int score) { Social.ReportScore(score, "leaderboardId", (bool success) => { Debug.Log("Report score to leaderboard " + success.ToString()); }); }

Please help I am stuck on this for many days now!!!!!!!

soham387 avatar May 17 '18 03:05 soham387

This is year 2022... I'm done looping through all the possible issues to find a solution. I have the same problem, login is successful, I can post scores but can not show leaderboards from my game.

Any advice? Maybe during this 4 year period you find a solution?

Note: I also don't see a confirmation popup for sign-in.

aeaktepe avatar Mar 28 '22 15:03 aeaktepe