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

Load Scores failed

Open andrex903 opened this issue 4 years ago • 7 comments

ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard();
lb.id = LEADERBOARD_ID;	 		
lb.LoadScores(success =>
	{
		if (success) callback(lb.scores); 
		else callback(null);
	});

if i use this code i have no errors and i can retrieve the local player rank and score, but when i try to create a custom leadeboard UI i get the out of date scores. I see a similar issue here (https://github.com/playgameservices/play-games-plugin-for-unity/issues/2674) due to a bug with LeaderboardStart.PlayerCentered. So i try this code

PlayGamesPlatform.Instance.LoadScores(
            LEADERBOARD_ID,
            LeaderboardStart.TopScores,
            100,
            LeaderboardCollection.Public,
            LeaderboardTimeSpan.AllTime,
            (data) => callback(data.Scores));

But when i build i get a message in the logcat and nothing happens

8877 8877 Info Unity: GooglePlayGames.Android.<>c__DisplayClass49_0:<LoadScores>b__1(AndroidJavaObject)
8877 8877 Info Unity: System.Action`1:Invoke(T)
8877 8877 Info Unity: GooglePlayGames.Android.TaskOnFailedProxy:onFailure(AndroidJavaObject)
8877 8877 Info Unity: System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
8877 8877 Info Unity: UnityEngine.AndroidJavaProxy:Invoke(String, Object[])
8877 8877 Info Unity: UnityEngine._AndroidJNIHelper:InvokeJavaProxyMethod(AndroidJavaProxy, IntPtr, IntPtr)

So for now i use Social.ShowLeaderboardUI() but i need to use a custom UI so i can show additional informations.

andrex903 avatar Dec 08 '19 16:12 andrex903

I'm having a similar issue when using that version of LoadScores. This has always worked for our game in the past, but is now giving us problems after trying to do an update. We're using an encoding for our scores that makes no sense when shown raw in the native leaderboard UI, so this has rendered us unable to show user scores.

jsmacdou avatar Dec 09 '19 19:12 jsmacdou

I get the same error. But it's weird, because it worked normally and even though I haven't touched the related code it stopped working and shows that same error that you get.

It works when I set the number of scores displayed to a max of 30, but it stops working after some time. Not sure what is happening.

PeteZaGames avatar Dec 09 '19 22:12 PeteZaGames

I'm experiencing the same problem

mgrogin avatar Dec 18 '19 10:12 mgrogin

For me the issue seems to be with the rowCount parameter and the LeaderboardMaxResults What I changed for now is in PlayGamesPlatform.LoadScores(ILeaderboard board, Action callback) I call mClient.LoadScores( board.id, LeaderboardStart.PlayerCentered, Math.Min(board.range.count, mClient.LeaderboardMaxResults()), //10, board.userScope == UserScope.FriendsOnly ? LeaderboardCollection.Social : LeaderboardCollection.Public, timeSpan, (scoreData) => HandleLoadingScores( (PlayGamesLeaderboard)board, scoreData, callback)); https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/source/PluginDev/Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs line 1276

I hope this helps identify the problem...

mgrogin avatar Dec 18 '19 12:12 mgrogin

@mgrogin Thanks for tracking this down! Making sure my rowCount value was capped fixed a hang issue for our project.

DunkUK avatar Jan 14 '20 11:01 DunkUK

I had the same issue. When I changed it to 16 it worked perfectly well. I don't know if this has anything to do with platform dependency but perhaps it might be better to change the value in the example with something between 1-30 so that people won't have that issue. Especially for people who are new to this leaderboard thing like me, It might be quiet difficult to resolve the issue. Just my humble opinion. Best wishes everyone

Heraklaitos avatar Jul 21 '20 08:07 Heraklaitos

Hi all, I faced the same problem and have made changes to the code to call LoadScores and LoadMoreScores method in the client recursively and return an entire list according to the rowCount input. Hence the rowCount parameter from my changes can be more than LeaderboardMaxResults.

The question is, is this a good approach? As it is calling the API many times till the rowCount is fulfilled. If it's all good, I plan to make a PR once I've refined the code a bit.

tyrng avatar Mar 14 '22 23:03 tyrng