Exemplo n.º 1
0
        private void CleanAllWndSync()
        {
            for (int i = 0, iMax = mCurShowUIIDList.Count; i < iMax; ++i)
            {
                UIType    hideID  = mCurShowUIIDList[i];
                UIWndBase hideWnd = GetUIWnd(hideID);
                if (hideWnd != null)
                {
                    hideWnd.OnHideWnd();
                    hideWnd.SetActiveByRoot(false);
                }
            }

            mCurShowUIIDList.Clear();
            mCurCacheUIIDList.Clear();
            var ie1 = m_mapAllUIWnd.GetEnumerator();

            while (ie1.MoveNext())
            {
                GameObject.Destroy(ie1.Current.Value.CachedGameObject);
            }

            m_mapAllUIWnd.Clear();

            // 释放所有UI资源
            for (int i = 0; i < mAssetList.Count; i++)
            {
                mAssetList[i].Destory();
            }

            mAssetList.Clear();

            //AppInterface.GUIModule.DestoryPlayerManagerGameObject();
            //AppInterface.GUIModule.DestroyBillboardUI();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 切换界面
        /// </summary>
        IEnumerator SwitchWndAsync(UIType targetID, UIType preID, bool bReturn, object exData, UIType[] hideId)
        {
            HideWndSync(hideId);
            if (targetID != UIType.None && !IsUIShowing(targetID))
            {
                UIWndBase targetWnd = GetUIWnd(targetID);
                if (targetWnd != null)
                {
                    targetWnd.ReadyShow = false;
                    targetWnd.SetActiveByRoot(false);
                    mCurShowUIIDList.Add(targetID);

                    UIWndData targetData = new UIWndData(preID, bReturn, exData);
                    targetWnd.OnShowWnd(targetData);

                    while (!targetWnd.ReadyShow)
                    {
                        if (targetWnd == null)
                        {
                            yield break;
                        }
                        yield return(null);
                    }

                    targetWnd.SetActiveByRoot(true);
                    targetWnd.OnReadShow();

                    // 小红点
                    //LittleRedPointManager.Singleton.Register(targetWnd as ILittleRedPointable);
                }
                else
                {
                    Log.Error($"ui should be prepared before switched: {targetID}");
                }
            }
        }
Exemplo n.º 3
0
        // ReSharper disable Unity.PerformanceAnalysis
        /// <summary>
        /// 准备显示的UI预设 加载
        /// </summary>
        IEnumerator PrepareUIAsync(UIType packageID, UIType uiID)
        {
            if (uiID != UIType.None)
            {
                UIWndBase uiWnd = GetUIWnd(uiID);
                if (uiWnd == null && !IsUICaching(uiID))
                {
                    mCurCacheUIIDList.Add(uiID);

                    // load ui from bundle
                    UGUIAssetItem asset = new UGUIAssetItem(UGUIAssetItem.AssetType.Prefab, packageID, uiID);
                    mAssetList.Add(asset);
                    bool loaded = false;
                    asset.Load(() =>
                    {
                        asset.AddToCanvas();
                        loaded = true;
                    });
                    while (!loaded)
                    {
                        yield return(null);
                    }

                    // 加载UI的Awake中调用了RegisterUI(UIWndBase uiWnd)方法。已加入map
                    uiWnd = GetUIWnd(uiID);
                    if (uiWnd != null)
                    {
                        uiWnd.SetActiveByRoot(true);
                    }
                    else
                    {
                        Debug.LogError($"prepare ui failed: {uiID}");
                    }
                }
            }
        }