Esempio n. 1
0
    public static void AsyncLoad(UIASSETS_ID id, bool isCollider = true)
    {
        bool mustReturn = StageMgr.Loading;

        string uiResPath = GlobalInstanceFunction.Instance.GetAssetsName((int)id, AssetLoader.EAssetType.ASSET_UI);

        if (string.IsNullOrEmpty(uiResPath))
        {
            if (id == UIASSETS_ID.UIASSETS_MessageBoxPanel)
            {
                uiResPath  = "MessageBoxPanel";
                mustReturn = false;
            }
            if (id == UIASSETS_ID.UIASSETS__ErrorTipsUI)
            {
                uiResPath  = "PromptMessgaePanel";
                mustReturn = false;
            }
            if (id == UIASSETS_ID.UIASSETS_NoticePanel)
            {
                uiResPath  = "UpdateNotice";
                mustReturn = false;
            }
            if (id == UIASSETS_ID.UIASSETS_NetWaitPanel)
            {
                uiResPath = "NetWaitPanel";
            }
        }

        if (mustReturn)
        {
            return;
        }

        if (UIManager.Instance.ContainsUI4zhizuo(uiResPath))
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("zanweikaifang"));
            return;
        }
        foreach (UIShowCmd cmd in _PanelShowStates.Values)
        {
            if (cmd == UIShowCmd.Showing)
            {
                ClientLog.Instance.Log(" return  AsyncLoad    " + id);
                if (id != UIASSETS_ID.UIASSETS_MessageBoxPanel &&
                    id != UIASSETS_ID.UIASSETS_NpcTaskPanel)
                {
                    return;
                }
            }
        }


        if (_PanelShowStates.ContainsKey(uiResPath) && _PanelShowStates[uiResPath] != UIShowCmd.Hide)
        {
            if (_PanelShown.ContainsKey(uiResPath))
            {
                _PanelShown[uiResPath].Show();
            }

            return;
        }

        _PanelShowStates[uiResPath] = UIShowCmd.Showing;

        if (UIManager.Instance.ContainsUI4Loading(uiResPath))
        {
            ApplicationEntry.Instance.ShowUILoading();
        }

        UIAssetMgr.LoadUI(uiResPath, (Assets, paramData) =>
        {
            if (null == Assets || null == Assets.mainAsset)
            {
                ApplicationEntry.Instance.HideUILoading();
                return;
            }

            GameObject go = (GameObject)GameObject.Instantiate(Assets.mainAsset) as GameObject;
            if (isCollider)
            {
                if (id != UIASSETS_ID.UIASSETS_NpcTaskPanel)
                {
                    GlobalInstanceFunction.Instance.MakeUIMask(go);
                }
            }

            UIBase ui     = go.GetComponent <UIBase>();
            ui._UIResPath = uiResPath;

            ui.AttachToGameObject(go);

            if (_PanelShowStates[uiResPath] == UIShowCmd.Hide)
            {
                ui.Hide();
            }
            else
            {
                _PanelShowStates[uiResPath] = UIShowCmd.Shown;
                _PanelShown[uiResPath]      = ui;
                ui.Show();
            }
            ApplicationEntry.Instance.HideUILoading();
        }
                          , null);
    }