playgameservices / play-games-plugin-for-unity

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

Google Play Service UI not showing at all #2087

Open KhalidSaud opened 6 years ago

KhalidSaud commented 6 years ago

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());
    });
}

} `

AnnCoa commented 6 years ago

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.

Sonic1305 commented 6 years ago

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

GhassanF commented 6 years ago

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.

AnnCoa commented 6 years ago

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?

ilterbilguven commented 6 years ago

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.

GhassanF commented 6 years ago

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");
        }
    }
}

}

ilterbilguven commented 6 years ago

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

zeyangl commented 6 years ago

same here. wtf...

luisjuniorj commented 6 years ago

Any updates on this?

zeyangl commented 6 years ago

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.

soham387 commented 6 years ago

@zeyangl Could you please elaborate?

soham387 commented 6 years ago

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!!!!!!!

aeaktepe commented 2 years ago

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.