Ejemplo n.º 1
0
        public AbstractPanel GetPanel(UIID uiID)
        {
            PanelData panelData = null;
            var       data      = UIDataTable.Get(uiID);

            if (data != null)
            {
                panelData = data as PanelData;
            }
            AbstractPanel panel = null;

            if (!m_AllPanelMap.TryGetValue(uiID, out panel))
            {
                GameObject panelGo = null;
                GameObject uiGo    = m_UILoader.LoadSync(data.fullPath) as GameObject;
                panelGo = GameObject.Instantiate(uiGo);
                panel   = panelGo.GetComponent <AbstractPanel>();
                m_AllPanelMap.Add(uiID, panel);
                panel.uiID = uiID;
            }

            if (panel != null)
            {
                panel.ShowMode = panelData.m_PanelShowMode;
                switch (panel.ShowMode)
                {
                case PanelShowMode.Normal:
                    panel.transform.SetParent(m_UIRoot.NormalRoot);
                    break;

                case PanelShowMode.Pop:
                    panel.transform.SetParent(m_UIRoot.PopRoot);
                    break;

                case PanelShowMode.HideOther:
                    panel.transform.SetParent(m_UIRoot.NormalRoot);
                    break;
                }

                panel.GetComponent <RectTransform>().offsetMax = new Vector2(0, 0);
                panel.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0);
                //panelGo.transform.localRotation = Quaternion.Euler(Vector3.zero);
                panel.transform.localScale    = Vector3.one;
                panel.transform.localPosition = Vector3.zero;
                return(panel);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public void ClosePanel(UIID uiID)
        {
            PanelData panelData = null;
            var       data      = UIDataTable.Get(uiID);

            if (data != null)
            {
                panelData = data as PanelData;
            }
            AbstractPanel panel = null;

            if (m_CurrentShowMap.TryGetValue(uiID, out panel))
            {
                if (panel != null && panelData != null)
                {
                    m_CurrentShowMap.Remove(uiID);
                    m_CurrentShowList.Remove(panel);
                    panel.PanelClose();
                    switch (panelData.m_PanelShowMode)
                    {
                    case PanelShowMode.Pop:
                        if (m_PopStack != null && m_PopStack.Count > 0)
                        {
                            m_PopStack.Pop();
                            if (m_PopStack.Count > 0)
                            {
                                AbstractPanel topPanel = m_PopStack.Peek();
                                topPanel.PanelOpen();
                            }
                        }
                        break;

                    case PanelShowMode.HideOther:
                        m_UIRoot.NormalRoot.gameObject.SetActive(true);
                        m_UIRoot.PopRoot.gameObject.SetActive(true);
                        break;
                    }
                }
                else
                {
                    Log.I("Close Panel failed:" + uiID);
                }
            }
        }
Ejemplo n.º 3
0
        public static RectTransform FindTransformInPanel(string targetPanelName, string targetUINodePath)
        {
            UIData data = UIDataTable.Get(targetPanelName);

            if (data == null)
            {
                return(null);
            }
            AbstractPanel panel = UIMgr.S.GetPanel((UIID)data.uiID);//UIMgr.S.uiRoot.panelRoot.Find(targetPanelName);

            if (panel == null)
            {
                return(null);
            }

            Transform targetPanel = panel.transform;

            if (targetPanel == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(targetUINodePath))
            {
                return(targetPanel as RectTransform);
            }

            RectTransform result = targetPanel.Find(targetUINodePath) as RectTransform;

            if (result == null || !result.gameObject.activeSelf)
            {
                return(null);
            }

            return(result);
        }