Unity Google Play 游戏插件 - Sign in/Authentication 不工作
Unity Google Play Games plugin - Sign in/Authentication not working
我尝试了所有方法,但现在我已经被这个问题困扰了好几天。无论我尝试什么,Google Play 的登录屏幕都会在应用程序中打开,但随后突然停止并且用户未登录。
在分享代码之前,我先总结一下我所做的事情:
- 为Unity导入了GPG插件,最新版本,也尝试了旧版本但结果相同。我进行了设置,尝试在 jar 解析器上强制解析。
- 已创建使用密钥库签名的版本
- 已将已签名的 APK 上传到内部测试轨道
- Playstore 中的 GPG link 设置正确
- 尝试手动和通过 playstore 安装应用程序
- 创建了一个新项目,只测试GPG的登录部分,我分享的代码就是这个测试项目
- 尝试在 API 控制台中更改 SHA1 密钥,尝试所有可能的 APK 安装(Playstore/manual)和 SHA1 密钥(签名,上传)组合
- 将测试邮件添加到我和我同事的测试轨道,并启用这些邮件进行测试。
希望有人能帮助我。我再也无法在互联网上找到任何东西,而且我自己似乎也无法弄清楚这一点。这是唯一阻止我们发布第一款游戏的因素。
这是我用于测试应用程序的所有代码。我在场景中添加了一个按钮来登录 GPG 和 1 个文本字段来显示状态字符串。
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";
}
}
}
对于看到这个 post 并遇到同样问题的人:在您的代码中禁用已保存的游戏,然后登录就可以了。云保存现在坏了。下面 link 上的最新评论就是关于这个问题的。希望Google尽快修复它,云保存对于保存 IAP 购买等非常方便
https://github.com/playgameservices/play-games-plugin-for-unity/issues/2429
我尝试了所有方法,但现在我已经被这个问题困扰了好几天。无论我尝试什么,Google Play 的登录屏幕都会在应用程序中打开,但随后突然停止并且用户未登录。
在分享代码之前,我先总结一下我所做的事情:
- 为Unity导入了GPG插件,最新版本,也尝试了旧版本但结果相同。我进行了设置,尝试在 jar 解析器上强制解析。
- 已创建使用密钥库签名的版本
- 已将已签名的 APK 上传到内部测试轨道
- Playstore 中的 GPG link 设置正确
- 尝试手动和通过 playstore 安装应用程序
- 创建了一个新项目,只测试GPG的登录部分,我分享的代码就是这个测试项目
- 尝试在 API 控制台中更改 SHA1 密钥,尝试所有可能的 APK 安装(Playstore/manual)和 SHA1 密钥(签名,上传)组合
- 将测试邮件添加到我和我同事的测试轨道,并启用这些邮件进行测试。
希望有人能帮助我。我再也无法在互联网上找到任何东西,而且我自己似乎也无法弄清楚这一点。这是唯一阻止我们发布第一款游戏的因素。
这是我用于测试应用程序的所有代码。我在场景中添加了一个按钮来登录 GPG 和 1 个文本字段来显示状态字符串。
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";
}
}
}
对于看到这个 post 并遇到同样问题的人:在您的代码中禁用已保存的游戏,然后登录就可以了。云保存现在坏了。下面 link 上的最新评论就是关于这个问题的。希望Google尽快修复它,云保存对于保存 IAP 购买等非常方便
https://github.com/playgameservices/play-games-plugin-for-unity/issues/2429