【发布时间】:2019-04-16 06:06:23
【问题描述】:
为什么我的代码不起作用?我想在 auth OK 或 auth Failed 后更改 UI 状态。
Services.Api.Auth.SignInWithEmailAndPasswordAsync(_emailField.text, _passwordField.text).ContinueWith(auth =>
{
if (auth.IsFaulted || auth.IsCanceled)
{
Services.Loading.Hide();
Services.StateManager.ShowPopUp(Localisation.GetString("warningTitleText"), auth.Exception.Message.ToString());
Debug.LogFormat("<color=red><b>[WEB]</b></color>" + " AUTHORIZATION FAULTED");
return;
}
Services.Api.User = auth.Result;
Services.Photon.Connect();
Services.StateManager.Switch(nextState);
Debug.LogFormat("<color=red><b>[WEB]</b></color>" + " AUTHORIZATION OK: {0} ({1})",
Services.Api.User.DisplayName, Services.Api.User.UserId);
});
Debug.LogFormat 工作正常,但其他代码不工作:
Services.Loading.Hide();
Services.StateManager.ShowPopUp(Localisation.GetString("warningTitleText"), auth.Exception.Message.ToString());
或
Services.Photon.Connect();
Services.StateManager.Switch(nextState);
【问题讨论】:
-
我必须将此异步添加到方法中,并且可以等待在主线程中继续: public async void LoginButton_Click(GameObject newState) { Services.Loading.Show();等待 Services.Api.Auth.SignInWithEmailAndPasswordAsync(_emailField.text, _passwordField.text).ContinueWith(task => { _taskStatus = task; }); ...
标签: c firebase unity3d firebase-authentication