playgameservices / play-games-plugin-for-unity

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

Can't access Leaderboard data, callback is not called #964

Open ShinyArrow opened 8 years ago

ShinyArrow commented 8 years ago

Hello, As the title suggests. I've followed the same instructions in the README file and it doesn't seem to work. What I'm trying to do is get the leaderboard data and display them using my own UI.

I'm using the latest version of the plugin (0.9.30), installed the latest version of Google Play Service, Google Repository and Android Support Repository. I can login, set a score and I can use ShowLeaderboardUI(), the only thing that doesn't seem to work is actually accessing the leaderboard data.

Both of these methods doesn't work : 1-

    ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard();
    lb.id = GPManager.leaderboard_global_leaderboard;
    lb.LoadScores(ok =>
    {
        if (ok)
        {
            Debug.Log("Succesfully loaded");
        }
        else
        {
            Debug.Log("Error retrieving leaderboardi Way #1");
        }
    });

2-

    PlayGamesPlatform.Instance.LoadScores(GPManager.leaderboard_global_leaderboard,
        LeaderboardStart.TopScores,
        50, LeaderboardCollection.Public,
        LeaderboardTimeSpan.AllTime,
        (data) =>
        {
            Debug.Log("Found : " + data.Scores.Length + " scores");
        });

None of these methods prints anything, however, the first method returns a log that says :

[Play Games Plugin DLL] DEBUG: LoadScores,board=GooglePlayGames.PlayGamesLeaderboard callback is System.Action`1[System.Boolean]

while the second one doesn't even log anything. I've tried both Public and Social leaderboards but both doesn't work

711, #716 seems to have the same problem but I couldn't figure out how to implement the workaround mentioned in #731

ShinyArrow commented 8 years ago

Hello..?

claywilkinson commented 8 years ago

Do you see scores on the standard leaderboard UI? Can you share the complete log section from calling to get the data to the callback?

jarramono commented 8 years ago

@ShinyArrow if you still want to implement the workaround from #731, I added a comment that might help you creating the Android Plugin.

lorianla commented 8 years ago

@claywilkinson i have the same issue. I can't access the data from the leaderboard. The Leaderboard just show me a load icon nothing more.

VinQbator commented 8 years ago

Having the same issue here. I have no idea how to implement the workaround from #731. Showing the leaderboard with default ui works fine, but cant get the data to do my own leaderboard ui. Has anyone made the workaround plugin and can share it? Any other ways to get past this problem?

VinQbator commented 8 years ago

@ShinyArrow have you managed to get it work now? @jarramono can you please tell me more about how to create the plugin? And are you sure this is the same issue causing this as in #731, since in my case the callbacks dont get called at all and im not getting any score from the leaderboard, using both methods stated in first post here.

VinQbator commented 8 years ago

So, i figured out how to get it working while trying to implement this android plugin workaround. Found out that Debug.Log() appears in logcat and these lambda expressions actually get called, just unity log wont show them. Also, function calls wont work in the lambda expressions. So im assigning the lambda argument to a member variable and checking if the assignment is done in coroutine. I have no idea if there is a better way of doing this, but got it working. Hope this helps someone in the future.

Cevizli commented 8 years ago

I tried every function but not worked.So I look at logchat and I saw a error about threading (explanation -> #756).I changed my code to this ;

PlayGamesPlatform.Instance.LoadScores(ServiceIDs.leaderboard_level, LeaderboardStart.PlayerCentered,1, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime,(LeaderboardScoreData data) =>
         {

             PlayGamesHelperObject.RunOnGameThread(() =>
             {
                 StaticLogHelper.Log("OnILeaderbordLoaded");
             });
         });

and this is working fine now.

profmicrop commented 5 years ago

Hi,

Please help us. I have same problem.

PlayGamesPlatform.Instance.ShowLeaderboardUI(GPGSIds.leaderboard_myleaderboard); method is working.

But PlayGamesPlatform.Instance.LoadScores(... this method or alternative methods are not working.

PlayGamesPlatform.Instance.LoadScores( GPGSIds.leaderboard_myleaderboard, LeaderboardStart.TopScores, 100, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime, (data) => { mStatus += "Leaderboard data valid: " + data.Valid; mStatus += "\n approx:" + data.ApproximateCount + " have " + data.Scores.Length; });

Thanks