简体   繁体   中英

How to avoid locking UI when error logging in?

I'm creating a simple login/create user script. The problem is that whenever I log in unsuccessfully, the script freezes. Any idea how to fix this?

public void LoginButtonPressed()
{
    FirebaseAuth.DefaultInstance.SignInWithEmailAndPasswordAsync(EmailAddress.text, Password.text).
        ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("Login was canceled");
                userText = "2";
            }

            if(task.IsFaulted)
            {
                Debug.LogError("Error logging in");
                userText = "3";
            }

            if(task.IsCompleted)
            {
                Debug.LogFormat("Usermanager: User signed in successfully: {0}", EmailAddress.text);
                userText = "4";
                isLoadMainScene = true;
            }
        });
}

在此处输入图片说明

在此处输入图片说明

Using Debug.LogError(String) causes it to end the script.

Instead, use Debug.Log(String); to log messages and continue executing.

Even though you found an answer there are things you should know about logging:

Debug.Log is used to create a log without pausing.

Debug.LogWarning is used to create a warning massage without pausing.

Debug.LogError is used to create an error message with the ability to pause the code execution.


How to avoid locking UI when error logging in?

The pausing feature should not prevent you from using Debug.LogError . It is very helpful because it allows you to pause the code when you see the log in the Editor. If you want your log to be marked as "error", you can still use Debug.LogError and avoid this pausing when using Debug.LogError by disabling the "Error Pause" option in the Console tab.

在此处输入图片说明

See, the image above, it is enabled. Just click on "Error Pause" once to disable it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM