Beispiel #1
0
        public void CloseUI <T>(bool isCloseDirect, bool isRecorded) where T : ViewBaseFU_EX
        {
            PanelInfor infor = GetUIPanelByType <T>(typeof(T).Name, false); //不需要创建

            if (infor == null)
            {
                Debug.LogError("CloseUI Fail...Cant Get Panel " + typeof(T));
                return;
            }

            //if (typeof(T) == typeof(UIMainView))
            //{
            //    infor.m_ViewControlScript.Close();   //�ر���UI
            //    IsUIOpen = false;
            //    m_PreviousSelectView = null;
            //    return;
            //}// 主ui关闭 则关闭所有UI

            infor.m_ViewControlScript.Close(isCloseDirect);
            Debug.Log("Close Current UIPanel:: " + infor.m_Panel.name);

            if (isRecorded)
            {
                m_PreviousSelectView = null;
            }
        }
Beispiel #2
0
        /// <summary>
        ///Get UI Panel By Name
        /// </summary>
        /// <param name="panelName"></param>
        /// <returns></returns>
        PanelInfor LoadUIPanelByName(string panelName, bool createWhenNotExit)
        {
            if (string.IsNullOrEmpty(panelName))
            {
                Debug.Log("LoadUIPanelByName Fail , " + panelName);
                return(null);
            }

            UIPanelConfgInfor _confg = null;

            if (m_AllUIPanelConf.TryGetValue(panelName, out _confg) == false)
            {
                Debug.LogError("Loading Panel Not Exit" + panelName);
                return(null);
            }
            foreach (var item in m_AllInitialedPanel.Values)
            {
                if (item != null && item.m_Panel != null && item.m_Panel.name == panelName)
                {
                    return(item);
                }
            }

            Debug.Log("LoadUIPanelByName ..This Panel Not Initial Yet.. " + panelName);
            PanelInfor infor = CreatePanelByConfg(_confg, createWhenNotExit);

            return(infor);
        }
Beispiel #3
0
        /// <summary>
        /// 获得控制脚本
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="panelName"></param>
        /// <param name="createWhenNotExit"></param>
        /// <returns></returns>
        public T GetUIPanelControlByType <T>(string panelName, bool createWhenNotExit) where T : ViewBaseFU_EX
        {
            if (string.IsNullOrEmpty(panelName))
            {
                Debug.Log("GetUIPanelByType Fail , " + panelName);
                return(null);
            }
            PanelInfor infor = LoadUIPanelByName(panelName, createWhenNotExit);

            if (infor == null)
            {
                Debug.LogError("GetUIPanelByType Fail. Not Exit  " + typeof(T));
                return(null);
            }
            return(infor.m_ViewControlScript as T);
        }
Beispiel #4
0
        public void OpenUI <T>(bool isClosePrevious, string panelName, bool createWhenNotExit, bool needRecordAsCur) where T : ViewBaseFU_EX
        {
            PanelInfor infor = GetUIPanelByType <T>(panelName, createWhenNotExit);

            if (infor == null)
            {
                Debug.LogError("OpenUI Fail ...  Cant Get Panel Of " + typeof(T));
                return;
            }

            Debug.Log("Type " + typeof(T) + "  Name=" + typeof(T).Name);


            //if (typeof(T) == typeof(UIMainView))
            //{
            //    EventCenter.GetInstance().ResetUI();
            //    infor.m_ViewControlScript.Open();
            //    m_PreviousSelectView = null;
            //    IsUIOpen = true;
            //    return;
            //}


            infor.m_ViewControlScript.Open();
            if (isClosePrevious)
            {
                if (m_PreviousSelectView != null && m_PreviousSelectView.m_Panel != null && m_PreviousSelectView.m_Panel.name != infor.m_Panel.name)
                {
                    m_PreviousSelectView.m_ViewControlScript.Close();  //close Previous
                    Debug.Log("OpenUI.....Close Previous View " + m_PreviousSelectView.m_Panel.name);
                }
            }

            if (needRecordAsCur)
            {
                m_PreviousSelectView = infor; //Update Mark
            }
            return;
        }
Beispiel #5
0
        PanelInfor CreatePanelByConfg(UIPanelConfgInfor confg, bool createWhenNotExit)
        {
            if (confg == null)
            {
                Debug.LogError("SetPanelAtRightPanel Fail, Parameter is null");
                return(null);
            }
            Debug.Log("CreatePanelByConfg ....  " + confg.PanelName);

            #region Create Object BaseOn  confg

            //   GameObject uiAsset = null;
            GameObject obj = Resources.Load <GameObject>(ConstDefine.UIPanelResourcePath + confg.PanelPath);
            //   Manager.ins.ResourceMgr.LoadAsset(ConstDefine.UIPanelResourcePath + confg.PanelPath, (obj =>
            //    {
            //        uiAsset = obj as GameObject;
            //     }));
            //if (uiAsset == null)
            //{
            //    Debug.LogError("SetPanelAtRightPanel l Fail >>Panel Not Exit " + confg.PanelPath);
            //    return null;
            //}

            GameObject _panelObj = GameObject.Instantiate(obj);
            _panelObj.name = confg.PanelName;

            #endregion

            #region GetComponent Of This Obj ,Make Sure Inherit From ViewBaseFU_EX,Then Set Local psotion And Rotation
            Transform root = m_AllUIRootBaseOnLevelDic[confg.m_UIPanelLevel];
            if (root == null)
            {
                Debug.LogError("SetPanelAtRightPanel Fail,Root is Null");
                return(null);
            }
            if (confg.m_UIPanelLevel != UIPanelLevel.FixedDirectionUI || confg.IsParentRoot)
            {
                _panelObj.transform.SetParent(root);
                ///,Log4Helper.Info(">>>>>>> Set to Root");
            } //主UI 和 根节点UI设置
            else
            {
                PanelInfor _infor = LoadUIPanelByName("UIMainCanvasView", true);
                if (_infor == null)
                {
                    Debug.LogError("CreatePanelByConfg Fail....  UIMainCanvasView Not Exit");
                    _panelObj.transform.SetParent(root);
                }
                else
                {
                    _panelObj.transform.SetParent(_infor.m_Panel.transform);
                    _panelObj.transform.localScale = Vector3.one; //主要的UI

                    if (_panelObj.name != "UIMainView")
                    {
                        _panelObj.transform.SetAsFirstSibling();
                    }

                    Debug.Log(" CreatePanelByConfg. MainMenu.." + _panelObj.gameObject.name);
                }
            } //根据UI类型设置不同的父节点


            ViewBaseFU_EX _view = _panelObj.transform.GetComponent <ViewBaseFU_EX>();
            if (_view == null)
            {
                Debug.LogError("CreatePanelByConfg Fail..Miss ViewBaseFU_EX :" + _panelObj.name);
                return(null);
            }
            //Set Panel At Confg Position And Rotation
            _panelObj.transform.localPosition    = _view.m_InitialPosition;
            _panelObj.transform.localEulerAngles = _view.m_InitialAngle;

            #endregion

            #region Check And Record This Panel At m_AllInitialedPanel

            Type       type  = _view.GetType();
            PanelInfor infor = new PanelInfor(_panelObj, _view);
            if (m_AllInitialedPanel.ContainsKey(type) == false)
            {
                m_AllInitialedPanel.Add(type, infor);  //Record
            }
            else if (m_AllInitialedPanel[type] == null || m_AllInitialedPanel[type].m_Panel == null)
            {
                Debug.Log("CreatePanelByConfg , Object Destroyed ,Record Now " + confg.PanelName);
                m_AllInitialedPanel.Remove(type);
                m_AllInitialedPanel.Add(type, infor);  //Record
            }
            else
            {
                m_AllInitialedPanel[type] = infor;  //Record
            }

            #endregion

            _panelObj.gameObject.SetActive(false);
            return(infor);
        }