您好:我一直在努力让我的应用程序进行身份验证。我已将 APK 部署到我的 Galaxy 并发生以下情况:Unity 游戏打开,出现“连接到...”对话框,出现“Google Play”绿色对话框,对话框消失并带有加载指示器,然后我得到“错误”结果.
我在 Start() 中有以下内容:
PlayGamesPlatform.Activate();
PlayGamesPlatform.DebugLogEnabled = true;
AuthenticateGoogle();
以及 AuthenticateGoogle() 中的以下内容:
private bool AuthenticateGoogle()
{
isAuthorized = false;
Social.localUser.Authenticate((bool result) => {
isAuthorized = result;
if (!result)
{
GameObject.Find("errText").GetComponent<Text>().text = result.ToString();
}
});
return isAuthorized;
}
我使用 Unity UI 创建了一个新的 keystore ,输入了密码并构建了 .APK。然后我在 Google Play 控制台中创建了一个新应用程序并将 .APK 上传到它。接下来我创建了一个新的游戏服务并链接了该应用程序,允许它信任该应用程序。我创建了一个排行榜。我确保我的用户在测试部分。最后,我将 XML 从排行榜下的获取资源部分复制到我的 Unity 项目并构建项目,复制到我的手机。
有什么想法吗?我可以做些什么来解决身份验证与真/假结果的问题?
最佳答案
我假设您正在您的 Android 手机上测试它。
你应该尝试将它添加到你的 android mainfest 中:
<activity android:name="com.google.games.bridge.NativeBridgeActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
您可以在 Assets/Plugins/Android/AndroidMainfest.xml 中创建自定义 mainfest
将您自己添加到 Google Play 控制台上的测试人员(如果该应用处于测试阶段)并直接通过 Google Play 下载。 (不是测试构建和运行)
要跟踪此类错误,您可以使用工具 https://assetstore.unity.com/packages/tools/log-viewer-12047它使用简单,您可以了解哪里出了问题。希望它会有所帮助:)
编辑:
我使用的是不同的方法,但应该没什么区别:
public bool ConnectToGoogleServices()
{
if (!isConnectedToGoogleServices)
{
{
Social.localUser.Authenticate(success =>
{
isConnectedToGoogleServices = success;
});
}
}
return isConnectedToGoogleServices;
}
关于c# - Google Play 游戏在 Social.localUser.Authenticate 上返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47849461/