private string text;
void Start()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken().RequestServerAuthCode(false).Build();
text = "config created";
PlayGamesPlatform.InitializeInstance(config);
text = text + "\n" + "config initialized";
PlayGamesPlatform.Activate();
text = text + "\n" + "activated";
SignInWithPlayGames();
text = text + "\n" + "attempted to sign in";
}
public void SignInWithPlayGames()
{
UnityEngine.Social.localUser.Authenticate((bool success) =>
{
if (success)
{
string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
text = text + "\n" + "Auth code is: " + authCode;
if (string.IsNullOrEmpty(authCode))
{
text = text + "\n" + "Signed into Play Games Services but failed to get the server auth code.";
return;
}
}
if (!success)
{
text = text + "\n" + "Failed to Sign into Play Games Services.";
return;
}
});
}
当我在 Unity 上运行它时,我得到了
配置已创建配置已初始化激活无法登录 Play 游戏服务。试图登录
这很好,因为我正在使用我的 PC 来测试它。但在真实设备上运行我的应用程序后,我得到了一个有趣的结果。我懂了:
配置创建配置初始化激活尝试登录
我认为它会从 public void SignInWithPlayGames() 方法中跳过 if (success)。我的应用从不显示 Google Play UI,我现在不确定我是否使用了正确的代码。