繁体   English   中英

如何在 ContinueWith Firebase auth UNITY3D 中更改游戏对象

[英]How to change gameobjects in ContinueWith Firebase auth UNITY3D

为什么我的代码不起作用? 我想在 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);

从您提供的小代码中,我最好的猜测是您正在尝试从“Services.Api.Auth.SignInWithEmailAndPasswordAsync”创建的某个随机线程更改“UI 状态”。 我对 Unity 中的多线程不太熟悉,但通常 UI 可能只能由拥有它的线程更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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