为什么我的代码不起作用?验证成功或验证失败后,我想更改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);
答案 0 :(得分:0)
从您提供的最好的小代码中,您可能会试图从“ Services.Api.Auth.SignInWithEmailAndPasswordAsync”创建的一些随机线程更改“ UI状态”。我对Unity中的多线程不太熟悉,但是通常UI只能由拥有它的线程来更改。