playgameservices / play-games-plugin-for-unity

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

LeaderboardUI showing outdated scores #2903

Closed LeonardoMantovani closed 4 years ago

LeonardoMantovani commented 4 years ago

As the title says, I implemented today the Play Games Services in my Unity Game and when I look at the leaderboard it shows my first high score. Anyway, when I switched to the "Friends" tab instead of global for the first time I saw in "Friends" my current score (and now it shows that particular score in the Friends Tab and the first score in the Global tab, even if my current high score is different from both of them) I looked for a solution on the internet and I found that maybe changing "Types.DataSource.CACHE_OR_NETWORK" to "NETWORK_ONLY" in LeaderboardManager.cs could fix the problem. But I can't find this LeaderboardManager.cs file... Has it been removed? Where do I have to change Types.DataSource.CACHE_OR_NETWORK so?

olehkuznetsov commented 4 years ago

There is a cache which could live up to 1 hour. However current player scores should be updated in cache if they were reported for current player.

It is still possible to modify plugin if you want to always load fresh scores:

In AndroidClient.cs replace

                using (var task = client.Call<AndroidJavaObject>(
                    loadScoresMethod,
                    leaderboardId,
                    AndroidJavaConverter.ToLeaderboardVariantTimeSpan(timeSpan),
                    AndroidJavaConverter.ToLeaderboardVariantCollection(collection),
                    rowCount))

by

                using (var task = client.Call<AndroidJavaObject>(
                    loadScoresMethod,
                    leaderboardId,
                    AndroidJavaConverter.ToLeaderboardVariantTimeSpan(timeSpan),
                    AndroidJavaConverter.ToLeaderboardVariantCollection(collection),
                    rowCount,
                    /*forceReload=*/ true))
LeonardoMantovani commented 4 years ago

There is a cache which could live up to 1 hour. However current player scores should be updated in cache if they were reported for current player.

It is still possible to modify plugin if you want to always load fresh scores:

In AndroidClient.cs replace

                using (var task = client.Call<AndroidJavaObject>(
                    loadScoresMethod,
                    leaderboardId,
                    AndroidJavaConverter.ToLeaderboardVariantTimeSpan(timeSpan),
                    AndroidJavaConverter.ToLeaderboardVariantCollection(collection),
                    rowCount))

by

                using (var task = client.Call<AndroidJavaObject>(
                    loadScoresMethod,
                    leaderboardId,
                    AndroidJavaConverter.ToLeaderboardVariantTimeSpan(timeSpan),
                    AndroidJavaConverter.ToLeaderboardVariantCollection(collection),
                    rowCount,
                    /*forceReload=*/ true))

Do I have to leave forceReload commented (keeping / /) or not? Because if I remove the "comment brackets" it says Cannot resolve symbol forceReload

olehkuznetsov commented 4 years ago

yes it just comment to 'true' value. To describe it's meaning.