如何只显示一次 Google play 登录对话框?

问题描述 投票:0回答:0

我在我的 unity 游戏中使用 Google Play 游戏服务,我想静默登录我的游戏,以便顶部的对话框弹出窗口只显示一次。 现在每次我打开游戏时都会出现对话。像这样

完成对话大约需要 5 秒,这就是为什么我想静默进行,以便用户可以直接进入游戏,如果他们刚刚登录。

我在一些游戏中看到,当我们第一次打开游戏时,只有对话才会出现,然后再打开对话就不会出现,我们直接进入游戏。

我的密码是

  void Start()
{

    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
    .AddOauthScope("profile")
    .RequestServerAuthCode(false)
    .Build();
    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();
    
   if (!PlayGamesPlatform.Instance.localUser.authenticated)
    {
        Debug.Log("We're not authenticated in, let's authenticate first");
        PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, 
      (code) =>
        {
            if (code == SignInStatus.Success)
            {
                Debug.Log("We're not signed in, let's signin first");

                /// Signed in! Hooray!
                PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
                {
                    ServerAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode(),
                    CreateAccount = true,
                }, OnGoogleLoginSuccess, error =>
                {
                    Debug.Log("Error " + code);
                    // TODO: Move to splash scene with practice mode only
                });
            }
            else
            {
                /// Error signing in. We'll want to show a sign in button
            }
        });   /// <--- That "true" is very important!
    }
    else
    {
        Debug.Log("We're already signed in");
     }

}

所以主要问题是PlayGamesPlatform.Instance.localUser.authenticated 总是返回 false.

谢谢!

unity3d google-play-services google-play-games
© www.soinside.com 2019 - 2024. All rights reserved.