Ejemplo n.º 1
0
            public void LoadPanelResAsync()
            {
                if (m_PanelState != ePanelState.UnInit)
                {
                    return;
                }

                m_PanelState = ePanelState.Loading;

                UIData data = UIDataTable.Get(m_UIID);

                if (data == null)
                {
                    return;
                }

                PrepareDynamicResource(data);

                m_ResLoader.Add2Load(data.fullPath, (state, res) =>
                {
                    if (!state)
                    {
                        return;
                    }

                    OnPanelResLoadSuccess((GameObject)res.asset);
                });

                m_ResLoader.LoadSync();
            }
Ejemplo n.º 2
0
        public void ShortCachePanel <T>(T uiID, int cacheCount) where T : IConvertible
        {
            UIData data = UIDataTable.Get(uiID.ToInt32(null));

            if (data == null)
            {
                return;
            }

            data.shortCacheCount = cacheCount;
        }
Ejemplo n.º 3
0
        private void ClosePanelInfo(PanelInfo panelInfo)
        {
            if (panelInfo == null)
            {
                return;
            }

            //删除对自己的引用
            panelInfo.RemoveMaster(panelInfo.panelID);

            if (panelInfo.nextMaster > 0)
            {
                //重新调整层级就行
            }
            else             //该面板已经没有任何依赖
            {
                UIData data = UIDataTable.Get(panelInfo.uiID);

                bool destroy = true;
                if (data != null && data.cacheCount > 0)
                {
                    if (GetActiveAndCachedUICount(panelInfo.uiID) <= data.cacheCount)
                    {
                        destroy = false;
                    }
                }

                RemovePanelInfo(panelInfo);

                //恢复层级记录
                m_UIRoot.ReleasePanelSortingOrder(panelInfo.sortIndex);

                //处理是否真正销毁面板逻辑
                if (destroy)
                {
                    panelInfo.ClosePanel(destroy);
                }
                else
                {
                    m_CachedPanelList.Add(panelInfo);
                    panelInfo.ClosePanel(destroy);
                }

                //该面板的删除将影响它的依赖面板
                CheckNeedClosePanel(panelInfo.panelID);

                if (destroy)
                {
                    ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);
                }
            }
        }
Ejemplo n.º 4
0
            private void OnPanelResLoadSuccess(GameObject prefab)
            {
                if (m_NextMaster < 0)
                {
                    Log.i("PanelInfo Already Close,But Still Call OnPanelResLoadSuccess");
                    m_PanelState = ePanelState.UnInit;
                    return;
                }

                if (prefab == null)
                {
                    UIData data = UIDataTable.Get(m_UIID);
                    Log.e(string.Format("Failed to Load UI Prefab:{0} Path:{1}", m_UIID, data.fullPath));
                    return;
                }

                m_PanelState = ePanelState.Ready;

                GameObject go = UIMgr.Instance.InstantiateUIPrefab(prefab);

                go.SetActive(false);
                UIMgr.Instance.InitPanelParem(go);

                AbstractPanel panel = go.GetComponent <AbstractPanel>();

                if (panel == null)
                {
                    //该类型面板不纳入管理
                    go.gameObject.SetActive(true);
                    Log.e("Not Find Panel Class In Prefab For Panel:" + m_UIID);
                    //需要删除PanelInfo From Activity.
                    return;
                }

                panel.customVisibleFlag = m_CustomVisibleFlag;

                UIData panelData = UIDataTable.Get(m_UIID);

                if (panelData.panelClassType != null)
                {
                    if (panel.GetType() != panelData.panelClassType)
                    {
                        Log.e("ERROR: Prefab Bind C# Class Is Not Same With Define:" + panelData.name);
                    }
                }

                abstractPanel = panel;

                UIMgr.Instance.SetPanelSortingOrderDirty();
            }
Ejemplo n.º 5
0
        private AbstractPage ProcessAttachPage(int panelID, int uiID, GameObject go)
        {
            if (go == null)
            {
                return(null);
            }

            PanelInfo panelInfo = FindPanelInfoByPanelID(panelID);

            if (panelInfo == null || panelInfo.abstractPanel == null)
            {
                Log.e("AttachPage Failed To Find Panel:" + panelID);
                return(null);
            }

            panelInfo.SetSortingOrderDirty();

            AbstractPage page = go.GetComponent <AbstractPage>();

            if (page == null)
            {
                Log.e("Failed To Find Page In UI:" + uiID);
                go.SetActive(true);
                SetPanelSortingOrderDirty();
                return(null);
            }

            UIData panelData = UIDataTable.Get(uiID);

            if (panelData.panelClassType != null)
            {
                if (page.GetType() != panelData.panelClassType)
                {
                    Log.e("ERROR: Prefab Bind C# Class Is Not Same With Define:" + panelData.name);
                }
            }

            page.parentPage = panelInfo.abstractPanel;

            page.uiID = uiID;

            go.SetActive(true);

            page.OpenPage();

            SetPanelSortingOrderDirty();

            return(page);
        }
Ejemplo n.º 6
0
            public void LoadPageResAsync(int uiID, Transform parent, bool singleton, Action <AbstractPage> listener)
            {
                UIData data = UIDataTable.Get(uiID);

                if (data == null)
                {
                    Log.e("Failed to load UI, Not Find UIData For:" + uiID);
                    return;
                }

                if (singleton)
                {
                    if (m_PageWrapList == null)
                    {
                        m_PageWrapList = new List <PageWrap>();
                    }

                    PageWrap wrap = FindPageWrap(uiID);

                    if (wrap != null)
                    {
                        wrap.AddListener(listener);
                        return;
                    }
                    else
                    {
                        wrap = new PageWrap(uiID);
                        wrap.AddListener(listener);

                        m_PageWrapList.Add(wrap);
                    }
                }

                PrepareDynamicResource(data);

                m_ResLoader.Add2Load(data.fullPath, (state, res) =>
                {
                    if (!state)
                    {
                        return;
                    }

                    OnPageResLoadSuccess(uiID, parent, (GameObject)res.asset, singleton, listener);
                });

                m_ResLoader.LoadSync();
            }
Ejemplo n.º 7
0
        private PanelInfo LoadPanelInfo(int uiID)
        {
            UIData data = UIDataTable.Get(uiID);

            if (data == null)
            {
                Log.e("Failed to OpenPanel, Not Find UIData for UIID:" + uiID);
                return(null);
            }

            bool      needAdd   = true;
            PanelInfo panelInfo = GetPanelFromCache(uiID, true);

            if (panelInfo == null)
            {
                //缓存中没有,判断当前Panel 是否只支持单例
                if (data.isSingleton)
                {
                    //去当前所有已经开启的面板中寻找
                    panelInfo = GetPanelFromActive(uiID);
                }

                if (panelInfo == null)
                {
                    panelInfo = ObjectPool <PanelInfo> .Instance.Allocate();

                    panelInfo.Set(uiID, nextPanelID);
                }
                else
                {
                    needAdd = false;
                }
            }

            if (needAdd)
            {
                AddPanelInfo(panelInfo);
            }

            return(panelInfo);
        }
Ejemplo n.º 8
0
        public void UnShortCachePanel <T>(T uiID, bool clean = true) where T : IConvertible
        {
            UIData data = UIDataTable.Get(uiID.ToInt32(null));

            if (data == null)
            {
                return;
            }

            data.shortCacheCount = 0;

            if (data.cacheCount > 0)
            {
                return;
            }

            if (!clean)
            {
                return;
            }

            for (int i = m_CachedPanelList.Count - 1; i >= 0; --i)
            {
                if (i >= m_CachedPanelList.Count)
                {
                    continue;
                }

                PanelInfo panelInfo = m_CachedPanelList[i];

                UIData data2 = UIDataTable.Get(panelInfo.uiID);
                if (data2.cacheCount < 1)
                {
                    m_CachedPanelList.RemoveAt(i);

                    GameObject.Destroy(panelInfo.abstractPanel.gameObject);

                    ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);
                }
            }
        }
Ejemplo n.º 9
0
        protected void AddAssistUI2Holder(EngineUI uiid)
        {
            var data = UIDataTable.Get(uiid);

            m_Loader.Add2Load(data.fullPath);
        }