问题描述
在过去的几天里,我一直试图在Unity游戏中登录Google Play游戏,但无法正常工作。
代码:
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
public class SignInOnClick : MonoBehaviour
{
// Use this for initialization
void Start()
{
// Initialize Play Games Configuration and Activate it.
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.RequestServerAuthCode(false /*forceRefresh*/)
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
Debug.LogFormat("SignInOnClick: Play Games Configuration initialized");
}
public void SignInWithPlayGames()
{
Social.localUser.Authenticate((bool success) => {
if (success)
{
Debug.LogFormat("SignInOnClick: Succes!");
} else
{
Debug.LogFormat("SignInOnClick: Fail!");
}
});
}
}
我已按照以下步骤进行配置:
- 在Google Play控制台中添加新的游戏服务(选项:我的游戏中尚未使用任何Google API)
- 填写游戏详细信息以获取绿色标记
- 链接的应用程序> Android(正确的软件包名称,与Unity中的名称相同)
- 使用通过keytool命令获得的SHA1指纹对我的应用进行授权
- 添加了页首横幅,然后我从“获取资源”中复制了XML
- 将我的电子邮件地址添加到Play控制台中的“测试”页面
- 在Unity中,我运行了Android安装程序,并从链接的应用程序中粘贴了XML和客户端ID
问题:
当我通过Unity“构建并运行”游戏时,该游戏会出现在我的手机上。现在,我有一个连接到脚本的按钮(请参见上面的代码)。我单击按钮并在Visual Studio 2019中调试。
问题在于Social.localUser.Authenticate
总是返回false。
我在做什么错?我已经尝试过“ Force Resolver”,并且成功了。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)