コード例 #1
0
ファイル: UIManager.cs プロジェクト: 37Sir/WarChess
        void ShowPanel(UIPanelLayerData panelLayerData)
        {
            panelLayerData.active = true;
            UIPanelData panelData = GetPanelData(panelLayerData.name);

            m_OpenRequest.Add(panelLayerData);
            if (panelLayerData.gameObject == null)
            {
                if (!panelLayerData.doInstance)
                {
                    panelLayerData.doInstance = true;
                    App.ObjectPoolManager.Instantiate(panelLayerData.resourceName, (GameObject obj) =>
                    {
                        panelLayerData.gameObject           = obj;
                        panelLayerData.canvas               = obj.GetComponent <Canvas>();
                        panelLayerData.panel                = obj.GetComponent <Panel>();
                        panelLayerData.canvas.worldCamera   = this.m_UICamera;
                        panelLayerData.canvas.sortingOrder  = panelLayerData.zIndex;
                        panelLayerData.canvas.planeDistance = 1;
                        panelLayerData.panel.UpdateChildrenOrder(panelLayerData.zIndex);
                        panelLayerData.gameObject.name = panelLayerData.name;
                        panelLayerData.gameObject.transform.SetParent(this.m_UIRoot.transform);
                        panelLayerData.gameObject.transform.localScale    = Vector3.one;
                        panelLayerData.gameObject.transform.localPosition = Vector3.zero;
                    });
                }
            }
            else
            {
                panelLayerData.canvas.sortingOrder = panelLayerData.zIndex;
                panelLayerData.panel.UpdateChildrenOrder(panelLayerData.zIndex);
                panelLayerData.gameObject.name = panelLayerData.name;
                panelLayerData.gameObject.transform.SetParent(this.m_UIRoot.transform);
                panelLayerData.gameObject.transform.localScale    = Vector3.one;
                panelLayerData.gameObject.transform.localPosition = Vector3.zero;
                bool needOpenView = !panelLayerData.gameObject.activeSelf;
                if (!panelLayerData.inited)
                {
                    panelLayerData.inited = true;
                    if (panelLayerData.panel != null && !panelLayerData.panel.isInited)
                    {
                        panelLayerData.gameObject.SetActive(true);
                        panelLayerData.panel.InitView(panelData.canRepeat);
                        needOpenView = true;
                    }
                }
                if (needOpenView)
                {
                    panelLayerData.gameObject.SetActive(true);
                    if (panelLayerData.panel != null)
                    {
                        panelLayerData.panel.OpenView();
                        panelLayerData.intent = null;
                    }
                }
            }
        }
コード例 #2
0
ファイル: UIManager.cs プロジェクト: 37Sir/WarChess
        public string GetPanelResourceName(string panel)
        {
            UIPanelData data = GetPanelData(panel);

            if (data != null)
            {
                return(data.resourceName);
            }
            return("");
        }
コード例 #3
0
ファイル: UIManager.cs プロジェクト: 37Sir/WarChess
        public void RegisterPanel(string module, string name, UILayerType layerType, bool canRepeat)
        {
            UIPanelData panelData = new UIPanelData(module, name, layerType, canRepeat);

            if (!m_PanelMap.ContainsKey(name))
            {
                m_PanelMap.Add(name, panelData);
            }
            else
            {
                m_PanelMap[name] = panelData;
            }
            App.ObjectPoolManager.RegisteObject(panelData.resourceName, panelData.resourceName, 0, 30, -1);
        }
コード例 #4
0
ファイル: UIManager.cs プロジェクト: 37Sir/WarChess
 IEnumerator _DealOpenRequest()
 {
     while (m_OpenRequest.Count > 0)
     {
         UIPanelLayerData panelLayerData = m_OpenRequest[0];
         if (panelLayerData.gameObject != null)
         {
             UIPanelData panelData    = GetPanelData(panelLayerData.name);
             bool        needOpenView = !panelLayerData.gameObject.activeSelf;
             if (!panelLayerData.inited)
             {
                 panelLayerData.inited = true;
                 if (panelLayerData.panel != null && !panelLayerData.panel.isInited)
                 {
                     panelLayerData.gameObject.SetActive(true);
                     panelLayerData.panel.InitView(panelLayerData.gameObject);
                     needOpenView = true;
                 }
             }
             while (!panelLayerData.panel.isInited)
             {
                 yield return(new WaitForEndOfFrame());
             }
             if (needOpenView)
             {
                 panelLayerData.gameObject.SetActive(true);
                 if (panelLayerData.panel != null)
                 {
                     panelLayerData.panel.OpenView(panelLayerData.intent);
                     panelLayerData.intent = null;
                 }
             }
             if (!panelLayerData.active)
             {
                 HidePanel(panelLayerData);
             }
             m_OpenRequest.Remove(panelLayerData);
         }
         yield return(new WaitForEndOfFrame());
     }
     if (m_OpenRequestFinalHide != null)
     {
         for (int i = 0; i < m_OpenRequestFinalHide.Count; i++)
         {
             HidePanel(m_OpenRequestFinalHide[i]);
         }
     }
     m_OpenRequestFinalHide = null;
     m_OpenRequestDeal      = null;
 }
コード例 #5
0
ファイル: UIManager.cs プロジェクト: 37Sir/WarChess
        //打开panel
        public void OpenPanel(string name, object intent = null)
        {
            UIPanelData panelData = GetPanelData(name);

            if (panelData != null)
            {
                int curUid = m_LayersUidMap[panelData.layerLevel];
                List <UIPanelLayerData> panelLayerList = m_PanelLayerMap[panelData.layerType];
                UIPanelLayerData        panelLayerLast = null;

                //在此UI的层中检测 此UI是否已经打开以及是否可以重复打开
                for (int i = panelLayerList.Count - 1; i >= 0; i--)
                {
                    if (panelLayerList[i].name == name)
                    {
                        if (panelLayerList[i].active)
                        {
                            if (panelData.canRepeat)
                            {
                                break;
                            }
                            Debugger.LogError("Panel:" + name + " Already Opened. If You Want to Open Many, Please Set 'canRepeat' True in Register.");
                            return;
                        }
                        else
                        {
                            panelLayerLast = panelLayerList[i];
                            break;
                        }
                    }
                }
                if (panelLayerLast == null)
                {
                    //从未打开过,需要将UI的数据加入到 此UI的层次list里面
                    UIPanelLayerData layerData = new UIPanelLayerData();
                    layerData.name         = name;
                    layerData.resourceName = panelData.resourceName;
                    layerData.uid          = curUid;
                    layerData.baseUid      = curUid;
                    layerData.intent       = intent;
                    layerData.level        = panelData.layerLevel;
                    panelLayerList.Add(layerData);
                    m_LayersUidMap[layerData.level]++;
                }
                SortPanelLayer();
            }
        }