Example #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();
        }
Example #2
0
        public static UIWndBase GetUIWnd(UIType uiID)
        {
            UIWndBase result = null;

            if (uiID != UIType.None)
            {
                Singlton.m_mapAllUIWnd.TryGetValue(uiID, out result);
            }

            return(result);
        }
Example #3
0
 void RegisterWnd(UIWndBase uiWnd)
 {
     if (m_mapAllUIWnd.ContainsKey(uiWnd.UIID))
     {
         Debug.LogError("ui already register, please check : " + uiWnd.UIID.ToString());
     }
     else
     {
         m_mapAllUIWnd.Add(uiWnd.UIID, uiWnd);
         mCurCacheUIIDList.Remove(uiWnd.UIID);
     }
 }
Example #4
0
        void HideWndSync(UIType[] arHideID)
        {
            if (arHideID != null)
            {
                for (int i = 0, hideLength = arHideID.Length; i < hideLength; ++i)
                {
                    UIType hideID = arHideID[i];
                    if (IsUIShowing(hideID))
                    {
                        mCurShowUIIDList.Remove(hideID);

                        UIWndBase hideWnd = GetUIWnd(hideID);
                        if (hideWnd != null)
                        {
                            hideWnd.OnHideWnd();
                            //hideWnd.SetActiveByRoot(false);
                            DestroyWndSync(hideID);
                        }
                    }
                }
            }
        }
Example #5
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}");
                }
            }
        }
Example #6
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}");
                    }
                }
            }
        }
Example #7
0
 public static void RegisterUI(UIWndBase uiWnd)
 {
     Singlton.RegisterWnd(uiWnd);
 }