Мне нужно визуализировать панель с сообщениями об ошибках, чтобы информировать пользователя
но я не знаю, как получить исключение из задачи. Это код, когда я запускаю игру получаю эту ошибку и панель пуста и не активна:
SetActive можно вызывать только из основного потока.
Конструкторы и инициализаторы полей будут выполняться из потока загрузки при загрузке сцены.
Не используйте эту функцию в конструкторе или инициализаторах поля, вместо этого переместите код инициализации в функцию «Пробуждение» или «Запуск».
public void firebaseRegistration(string email, string password){
auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
if (task.IsCanceled) {
messagePanel.SetActive(true);
Debug.LogError("Task canceled");
message.GetComponent<Text>().text = "Task canceled";
return;
} else if (task.IsFaulted) {
string error = task.Exception.GetBaseException().ToString();
if (error.Contains("The email address is badly formatted")) {
Debug.LogError("The email address is badly formatted");
messagePanel.SetActive(true);
message.GetComponent<Text>().text = "The email address is badly formatted";
return;
}
if (error.Contains("The given password is invalid")) {
Debug.LogError("The given password is invalid");
messagePanel.SetActive(true);
message.GetComponent<Text>().text ="The given password is invalid";
return;
}
if (error.Contains("The email address is already in use by another account.")) {
Debug.LogError("The email address is already in use by another account.");
messagePanel.SetActive(true);
message.GetComponent<Text>().text = "The email address is already in use by another account.";
return;
}
Debug.LogError("Error during the creation of the user: " + task.Exception);
Debug.Log("Error code: " + task.Exception.GetBaseException());
return;
}
user = task.Result;
Debug.LogFormat("User created: {0} ({1})", user.DisplayName, user.UserId);
});
}