예제 #1
0
        public BaseUIPanel ShowUIForm(string uiFormName)
        {
            BaseUIPanel baseUiPanels = LoadFormsToAllUIFormsCache(uiFormName); //根据UI窗体的名称,加载到“所有UI窗体”缓存集合中
            if (baseUiPanels == null) return null;
            if (baseUiPanels.UIType.IsClearStack) ClearStackArray(); //是否清空“栈集合”中得数据

            //根据不同的UI窗体的显示模式,分别作不同的加载处理
            switch (baseUiPanels.UIType.UIForms_ShowMode)
            {
                case UIFormShowModes.Normal: //“普通显示”窗口模式
                    //把当前窗体加载到“当前窗体”集合中。
                    LoadUIToCurrentCache(uiFormName);
                    break;
                case UIFormShowModes.Return: //“反向切换”窗口模式
                    PushUIFormToStack(uiFormName);
                    break;
                case UIFormShowModes.ReturnHideOther: //“反向切换且隐藏其他窗口”窗口模式
                    EnterUIFormsAndHideOtherAndReturn(uiFormName);
                    break;
                case UIFormShowModes.HideOther: //“隐藏其他”窗口模式
                    EnterUIFormsAndHideOther(uiFormName);
                    break;
            }

            //LogError("showUI  " + uiFormName);
            return baseUiPanels;
        }
예제 #2
0
        void Update()
        {
            if (UIType.IsESCClose)
            {
                if (UIManager.Instance.CloseUIFormKeyDownHandler != null && UIManager.Instance.CloseUIFormKeyDownHandler.Invoke())
                {
                    BaseUIPanel peek = UIManager.Instance.GetPeekUIForm();
                    if (peek == null || peek == this)
                    {
                        closeFlag = true;
                        return;
                    }
                }
            }

            if (UIType.IsClickElsewhereClose)
            {
                bool mouseLeftDown    = UIManager.Instance.MouseLeftButtonDownHandler != null && UIManager.Instance.MouseLeftButtonDownHandler.Invoke();
                bool mouseRightDown   = UIManager.Instance.MouseRightButtonDownHandler != null && UIManager.Instance.MouseRightButtonDownHandler.Invoke();
                bool isClickElseWhere = (mouseLeftDown && !EventSystem.current.IsPointerOverGameObject()) || mouseRightDown;
                if (isClickElseWhere)
                {
                    BaseUIPanel peek = UIManager.Instance.GetPeekUIForm();
                    if (peek == null || peek == this)
                    {
                        closeFlag = true;
                        return;
                    }
                }
            }

            ChildUpdate();
        }
예제 #3
0
        /// <summary>
        /// 加载指定名称的“UI窗体”
        /// 功能:
        ///    1:根据“UI窗体名称”,加载预设克隆体。
        ///    2:根据不同预设克隆体中带的脚本中不同的“位置信息”,加载到“根窗体”下不同的节点。
        ///    3:隐藏刚创建的UI克隆体。
        ///    4:把克隆体,加入到“所有UI窗体”(缓存)集合中。
        /// 
        /// </summary>
        /// <param name="uiFormName">UI窗体名称</param>
        private BaseUIPanel LoadUIForm(string uiFormName)
        {
            GameObject UIPanel = LoadUIPanelHandler(uiFormName);
            BaseUIPanel baseUiPanel = UIPanel.GetComponent<BaseUIPanel>();
            if (baseUiPanel == null)
            {
                LogError("BaseUIPanel==null! ,请先确认窗体预设对象上是否加载了BaseUIForm的子类脚本! 参数 uiFormName=" + uiFormName);
                return null;
            }

            switch (baseUiPanel.UIType.UIForms_Type)
            {
                case UIFormTypes.Normal: //普通窗体节点
                    UIPanel.transform.SetParent(UINormalRoot, false);
                    break;
                case UIFormTypes.Fixed: //固定窗体节点
                    UIPanel.transform.SetParent(UIFixedRoot, false);
                    break;
                case UIFormTypes.PopUp: //弹出窗体节点
                    UIPanel.transform.SetParent(UIPopUpRoot, false);
                    break;
            }

            UIPanel.SetActive(false);
            AllUIFormDict.Add(uiFormName, baseUiPanel);
            return baseUiPanel;
        }
예제 #4
0
 //(“反向切换”属性)窗体的出栈逻辑
 private void PopUIForms()
 {
     if (CurrentUIFormsStack.Count >= 2)
     {
         BaseUIPanel topUiPanels = CurrentUIFormsStack.Pop();
         topUiPanels.Hide();
         BaseUIPanel nextUiPanels = CurrentUIFormsStack.Peek();
         nextUiPanels.Display();
     }
     else if (CurrentUIFormsStack.Count == 1)
     {
         BaseUIPanel topUiPanels = CurrentUIFormsStack.Pop();
         topUiPanels.Hide();
     }
 }
예제 #5
0
        /// <summary>
        /// UI窗体入栈
        /// </summary>
        /// <param name="uiFormName">窗体的名称</param>
        private void PushUIFormToStack(string uiFormName)
        {
            if (CurrentUIFormsStack.Count > 0)
            {
                BaseUIPanel topUiPanel = CurrentUIFormsStack.Peek();
                topUiPanel.Freeze();
            }

            AllUIFormDict.TryGetValue(uiFormName, out BaseUIPanel baseUIForm);
            if (baseUIForm != null)
            {
                baseUIForm.Display();
                CurrentUIFormsStack.Push(baseUIForm);
            }
            else
            {
                LogError("baseUIForm==null,Please Check, 参数 uiFormName=" + uiFormName);
            }
        }
예제 #6
0
 /// <summary>
 /// 显示(打开)UI窗体
 /// 功能:
 /// 1: 根据UI窗体的名称,加载到“所有UI窗体”缓存集合中
 /// 2: 根据不同的UI窗体的“显示模式”,分别作不同的加载处理
 /// </summary>
 public T ShowUIForms<T>() where T : BaseUIPanel
 {
     string uiFormNameStr = typeof(T).Name;
     BaseUIPanel uiPanel = ShowUIForm(uiFormNameStr);
     return (T) uiPanel;
 }
예제 #7
0
 public bool IsPeekUIForm<T>() where T : BaseUIPanel
 {
     BaseUIPanel peek = GetPeekUIForm();
     return peek != null && peek is T;
 }