问题快捷方式:我使用 firebaseAuth 登录后,unity ui 不响应代码。
问题是:连接到 firebaseAuth 后,如何更改 unity ui?
问题详细信息:我已经制作了一个 firebase 身份验证系统,它工作正常,所有按摩都在 system.print() 中打印得很好,但是当我需要在 UI.text 中显示 Auth 错误时,即使在登录成功后它也无法正常工作,我想要改变场景让玩家进入游戏,但 SceneManager.loadscene() 不起作用..
这是我的代码:
using UnityEngine;
using UnityEngine.UI;
using Firebase.Auth;
public class AccountsManager : MonoBehaviour
{
public void Login()
{
if (Email.text == "" && Password.text == "")
{
LoginMassageText.text = "Enter Email and Password";
}
else if (Email.text == "")
{
LoginMassageText.text = "Enter Email";
}
else if (Password.text == "")
{
LoginMassageText.text = "Enter Password";
}
else
{
FirebaseAuth.DefaultInstance.SignInWithEmailAndPasswordAsync(Email.text, Password.text).ContinueWith((task =>
{
if (task.IsCanceled)
{
Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;
ErroeHundler((AuthError)e.ErrorCode);
Debug.Log("1" + e);
return;
}
else if (task.IsFaulted)
{
Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;
ErroeHundler((AuthError)e.ErrorCode);
return;
}
else if (task.IsCompleted)
{
Debug.Log("login successful");
return;
}
}));
}
}
void ErroeHundler(AuthError Error)
{
print(Error.ToString());
LoginMassageText.text = "Invalid Email"; //this not working
switch(Error)
{
case AuthError.InvalidEmail:
LoginMassageText.text = "Invalid Email"; //this not working
print("invild");
break;
case AuthError.MissingEmail:
LoginMassageText.text = "Invalid Email"; //this not working
print("missingemail");
break;
default:
LoginMassageText.text = "Invalid Email"; //this not working
break;
}
}