Google Play 服务在验证后不显示排行榜

问题描述 投票:0回答:1

在这方面投入了很多时间,这很奇怪。所以在这里问。

我正在使用这个插件并按照步骤操作https://github.com/playgameservices/play-games-plugin-for-unity

我只想在发布模式下使用 Google Play 服务仅用于排行榜(我在 alpha 发布中使用)

这是我在 GPlay 服务中进行身份验证的代码:

void Awake(){
    PlayerPrefs.SetInt("GameOverCount",0);

    #if UNITY_ANDROID
    Authenticate ();
    #endif}

我已通过提供 10 多位客户端 ID 来配置 Gplay 设置

我已经使用我正在使用的release.keystore 的SHA1 从Google API 生成了OAuth 客户端ID。 在开发者控制台的 Gplay 服务中:我已发布链接的应用程序,没有任何错误

public void Authenticate() {
    if (Authenticated || mAuthenticating) {
        Debug.LogWarning("Ignoring repeated call to Authenticate().");
        return;
    }


    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        .EnableSavedGames()
            .Build();
    PlayGamesPlatform.InitializeInstance(config);

    // Activate the Play Games platform. This will make it the default
    // implementation of Social.Active
    PlayGamesPlatform.Activate();

    // Set the default leaderboard for the leaderboards UI
    ((PlayGamesPlatform) Social.Active).SetDefaultLeaderboardForUI(leaderboardID_android);



    // Sign in to Google Play Games
    mAuthenticating = true;
    Social.localUser.Authenticate((bool success) => {
        mAuthenticating = false;
        if (success) {

            UnityAnalytics.CustomEvent("Auth Completed", new Dictionary<string, object>
                                       {
                { "isAuthDone", true }
            });

            if(showScores){

                Social.Active.ShowLeaderboardUI();
                Debug.Log("should show leaderborad");
            }
            // if we signed in successfully, load data from cloud
            Debug.Log("Login successful!");
        } else {
            // no need to show error message (error messages are shown automatically
            // by plugin)
            Debug.LogWarning("Failed to sign in with Google Play Games.");

            UnityAnalytics.CustomEvent("Auth Failed", new Dictionary<string, object>
                                       {
                { "isAuthDone", false }
            });

        }
    });
}
#if UNITY_ANDROID
    if (Authenticated) {
        showScores = false;
        ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboardID_android);
        Social.ShowLeaderboardUI();
        Debug.Log("should show leaderborad");

        UnityAnalytics.CustomEvent("Authenticated and show android leaderboard", new Dictionary<string, object>
                                   {
            { "isShowing", true }
        });

    }else{
        showScores = true;
        Authenticate();
    }
    #endif

接下来,我发布 alpha 并检查 Android 设备 - 我看到一个屏幕,显示正在连接到 google play games...连接进程,然后关闭屏幕。 看起来它已经通过了身份验证并消失了。但由于某种原因不显示排行榜。我无法理解为什么会发生以及缺少什么。

在我的统一分析中,只有一次未加载分数并且我播放了 20-30 次: enter image description here

在我的开发者控制台中,分数数量为空:

enter image description here

任何人都可以帮忙吗,我可以向可以帮助/想要帮助的人提供更多详细信息....谢谢...

android unity-game-engine google-play google-play-services leaderboard
1个回答
0
投票

选择 Proguard for Minify > 发布 并将内容复制到 Assets/Plugins/Android/proguard-user.txt

-keep class com.google.unity.** {
   *;
}
-keep public class com.google.android.gms.ads.**{
   public *;
}
-keep public class com.google.ads.**{
   public *;
}
-keepattributes *Annotation*
-dontobfuscate
-keep class com.google.android.gms.games.PlayGames { *; }
-keep class com.google.android.gms.games.leaderboard.** { *; }
-keep class com.google.android.gms.games.snapshot.** { *; }
-keep class com.google.android.gms.games.achievement.** { *; }
-keep class com.google.android.gms.games.event.** { *; }
-keep class com.google.android.gms.games.stats.** { *; }
-keep class com.google.android.gms.games.video.** { *; }
-keep class com.google.android.gms.games.* { *; }
-keep class com.google.android.gms.common.api.ResultCallback { *; }
-keep class com.google.android.gms.signin.** { *; }
-keep class com.google.android.gms.dynamic.** { *; }
-keep class com.google.android.gms.dynamite.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
-keep class com.google.android.gms.security.** { *; }
-keep class com.google.android.gms.base.** { *; }
-keep class com.google.android.gms.actions.** { *; }
-keep class com.google.games.bridge.** { *; }
-keep class com.google.android.gms.common.ConnectionResult { *; }
-keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
-keep class com.google.android.gms.common.api.** { *; }
-keep class com.google.android.gms.common.data.DataBufferUtils { *; }
-keep class com.google.android.gms.games.quest.** { *; }
-keep class com.google.android.gms.nearby.** { *; }

这对我来说是工作。

© www.soinside.com 2019 - 2024. All rights reserved.