Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Unity项目上的Firebase auth.SignOut()_C#_Authentication_Firebase_Unity3d_Backend - Fatal编程技术网

C# Unity项目上的Firebase auth.SignOut()

C# Unity项目上的Firebase auth.SignOut(),c#,authentication,firebase,unity3d,backend,C#,Authentication,Firebase,Unity3d,Backend,我有这个问题已经有一段时间了。每次我让用户注销并尝试再次连接时,应用程序都会冻结并崩溃。知道会发生什么吗 注:起初我认为原因是有不止一个脚本处理firebase行为(我重新启动SplashScreen场景,其中使用unity的“DontDestroyOnLoad()”方法实例化了一个游戏对象)。所以我在一些重复的脚本中结束,我认为这可能是导致崩溃的原因,但我已经修复了它,崩溃还在继续 编辑:这是我用来登录用户的代码 public void SignInWithCredentials(string

我有这个问题已经有一段时间了。每次我让用户注销并尝试再次连接时,应用程序都会冻结并崩溃。知道会发生什么吗

注:起初我认为原因是有不止一个脚本处理firebase行为(我重新启动SplashScreen场景,其中使用unity的“DontDestroyOnLoad()”方法实例化了一个游戏对象)。所以我在一些重复的脚本中结束,我认为这可能是导致崩溃的原因,但我已经修复了它,崩溃还在继续

编辑:这是我用来登录用户的代码

public void SignInWithCredentials(string email, string password) {
    if (auth.CurrentUser == null && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password)) {
        Credential credential = EmailAuthProvider.GetCredential(email, password);
        auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
            if (task.IsCanceled) {
                Debug.Log("------------------------- User sign in canceled.");
            } else if (task.IsFaulted) {
                Debug.Log("------------------------- User sign in encountered an error.");

                ButtonManager.Instance.panelLoginInfo.GetComponent<UIControllerExample>().Play();

                foreach (var e in task.Exception.InnerExceptions) {
                    FirebaseException firebaseException = (FirebaseException)e;
                    Debug.Log("------------------------- " + firebaseException.Message);
                }
            } else if (task.IsCompleted) {
                Debug.Log("------------------------- User sign in completed.");
                if (auth.CurrentUser != null) {
                    Debug.Log("------------------------- User info: " + auth.CurrentUser.Email + "    " + auth.CurrentUser.ProviderId);
                }

                if (!auth.CurrentUser.IsEmailVerified) {
                    Debug.Log("------------------------- User not comfirmed your email. Send new verification.");
                    auth.CurrentUser.SendEmailVerificationAsync().ContinueWith(taskVerification => {
                        if (taskVerification.IsCanceled) {
                            Debug.Log("------------------------- User verification email canceled send.");
                        } else if (taskVerification.IsFaulted) {
                            Debug.Log("------------------------- User verification email encountered an error.");
                            foreach (var e in task.Exception.InnerExceptions) {
                                FirebaseException firebaseException = (FirebaseException)e;
                                Debug.Log("------------------------- " + firebaseException.Message);
                            }
                        } else if (taskVerification.IsCompleted) {
                            Debug.Log("------------------------- User verification email send.");

                            SaveSession.Instance.SaveUserCredentials();
                            StartCoroutine(WaitToLoadScene("EmailCheck"));
                        }
                    });
                } else {
                    Debug.Log("------------------------- User confirmed your email.");

                    SaveSession.Instance.SaveUserCredentials();
                    StartCoroutine(WaitToLoadScene("City"));
                }

            } else {
                Debug.Log("------------------------- Something really really wrong happen.");
            }
        });
    } else if (auth.CurrentUser != null) {
        Debug.Log("------------------------- You have user logged in: " + auth.CurrentUser.Email);
    } else if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) {
        Debug.Log("------------------------- Complete all blanck spaces.");
    }
} 

添加登录和注销脚本可能会有所帮助。你是使用电子邮件和密码认证还是谷歌或Facebook…好吧,我用我正在使用的代码编辑帖子。显然,此错误仅在电子邮件身份验证时发生,因为我在使用FB auth token执行此操作时未看到此错误。感谢您的帮助:)当unity崩溃或像unity冻结一样时,您没有收到任何错误吗?不,unity上的探查器卡住了,logcat没有显示任何错误。请尝试一步一步地调试代码,以便找到导致问题的行。
public void LogOut () {
    auth.SignOut();
    user.DeleteAsync();

    if (FB.IsLoggedIn) {
        FacebookManager.Instance.isLogIn = "false";
        PlayerPrefs.SetString("Login", FacebookManager.Instance.isLogIn);
        PlayerPrefs.Save();
        FB.LogOut();
    }

    if (File.Exists(credentialsPath)) {
        File.Delete(credentialsPath);
    }

    StartCoroutine(WaitToLoadScene("SplashScreen"));
}