我尝试了一切,现在我几乎坚持这个问题了。无论我尝试什么,Google Play的登录屏幕都会在应用中打开,但之后突然停止,用户也没有登录。
在分享代码之前,我将总结我所做的事情:
我希望有一个人可以帮助我。我在互联网上找不到任何东西,似乎无法自己解决这个问题。这是阻止我们发布第一款游戏的唯一因素。
这是我用于测试应用程序的所有代码。我在场景中添加了一个按钮以登录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";
}
}
}
我会在这个标签上标记。我遇到了同样的问题,遵循与您完全相同的步骤。看一下代码,它也很相似。
对于看到此帖并且遇到相同问题的人:在代码中禁用已保存的游戏并且登录将起作用。云存储现在被打破了。以下链接的最新评论涉及此问题。希望Google尽快修复它,云节省对于节省IAP购买等非常方便。
https://github.com/playgameservices/play-games-plugin-for-unity/issues/2429