Unity Google Play 游戏插件 - 登录/身份验证不起作用

Posted

技术标签:

【中文标题】Unity Google Play 游戏插件 - 登录/身份验证不起作用【英文标题】:Unity Google Play Games plugin - Sign in/Authentication not working 【发布时间】:2019-07-14 04:58:16 【问题描述】:

我尝试了所有方法,但我已经被这个问题困扰了好几天。无论我尝试什么,Google Play 的登录屏幕都会在应用中打开,但随后突然停止并且用户未登录。

在分享代码之前我先总结一下自己做过的事情:

为 Unity 导入了 GPG 插件,最新版本,也尝试了旧版本,但结果相同。我做了设置,尝试在 jar 解析器上强制解析。 已创建使用密钥库签名的构建 已将签名的 APK 上传到内部测试轨道 Playstore 中的 GPG 链接设置正确 尝试通过 Playstore 手动安装应用程序 新建一个项目只测试 GPG 的 Sign in 部分,我要分享的代码就是这个测试项目的代码 尝试在 API 控制台中更改 SHA1 密钥,尝试了 APK 安装(Playstore/手动)和 SHA1 密钥(签名、上传)的所有可能组合 将测试电子邮件添加到我和我同事的测试轨道,并启用这些电子邮件进行测试。

我希望有人可以帮助我。我再也无法在互联网上找到任何东西,而且我自己似乎也无法弄清楚这一点。这是阻止我们发布第一款游戏的唯一原因。

这是我用于测试应用的所有代码。我在场景中添加了一个按钮来登录 GPG,并添加了一个文本字段来显示状态字符串。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.SavedGame;
using UnityEngine.UI;

public class ClickManagerScript : MonoBehaviour


    public GameObject textField;

    public void LogInClick()
    
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .EnableSavedGames().Build();
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();

        SignIn();
    

    void SignIn()
    
        //when authentication process is done (successfuly or not), we load cloud data
        Debug.Log("Going to log in to GPG");
        Social.localUser.Authenticate(success =>  UpdateTextField(); );
    

    void UpdateTextField()
    
        Text text = textField.GetComponent<Text>();

        if (Social.localUser.authenticated)
        
            text.text = "Sign in succesfull";
        
        else
        
            text.text = "Sign in failed";
        
    

【问题讨论】:

【参考方案1】:

我会跟上这个。我遇到了同样的问题,按照与您完全相同的步骤进行操作。看代码,也很相似。

【讨论】:

【参考方案2】:

对于看到此帖子并遇到相同问题的人:在您的代码中禁用保存的游戏并且登录将起作用。云存储现在被打破了。以下链接上的最新 cmet 涉及此问题。希望谷歌尽快修复它,云保存对于保存 IAP 购买等非常方便。

https://github.com/playgameservices/play-games-plugin-for-unity/issues/2429

【讨论】:

以上是关于Unity Google Play 游戏插件 - 登录/身份验证不起作用的主要内容,如果未能解决你的问题,请参考以下文章

用于 Unity 的最新 Google Play 游戏服务插件无法正常工作

Unity AdMob 插件 2.3.1 版和 Unity Google Play 游戏插件 0.9.30 不能一起使用

Unity Google Play 游戏插件:错误未授权代码 13

Unity Google Play 游戏插件 - 登录/身份验证不起作用

Unity Android 游戏可以使用 Google Play 游戏插件登录,但无法从排行榜加载分数

Google Play 服务 Unity 插件显示排行榜