Beispiel #1
0
        /// <summary>
        /// 反向切换窗体的出栈逻辑
        /// </summary>
        private void PopUIForm()
        {
            if (_StaCurrentUIForms.Count >= 2)
            {
                BaseUIForm topUIForm = _StaCurrentUIForms.Pop();
                topUIForm.Hiding();

                BaseUIForm nextUIForm = _StaCurrentUIForms.Peek();
                nextUIForm.ReDisplay();
            }
            else if (_StaCurrentUIForms.Count == 1)
            {
                BaseUIForm topUIForm = _StaCurrentUIForms.Pop();
                topUIForm.Hiding();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 加载指定名称UI窗体
        /// </summary>
        /// <param name="uiFormName">UIPrefab名称</param>
        private BaseUIForm LoadForm(string uiFormName)
        {
            string     strUIFormPaths = string.Empty;
            GameObject goClonePrefabs = default(GameObject);
            BaseUIForm baseUIForm     = default(BaseUIForm);

            _DicFormsPaths.TryGetValue(uiFormName, out strUIFormPaths);
            if (!string.IsNullOrEmpty(strUIFormPaths))
            {
                goClonePrefabs = ResourcesMgr.Instance.LoadAsset(strUIFormPaths, false);
            }

            if (_TraCanvasTransform != null && goClonePrefabs != null)
            {
                baseUIForm = goClonePrefabs.GetComponent <BaseUIForm>();
                if (baseUIForm == null)
                {
                    Debug.LogError("BaseUIForm为空,窗体预制件上未加载BaseUIForm的子类脚本,Prefab=" + uiFormName);
                    return(null);
                }
                switch (baseUIForm.CurrentUIType.UIForm_Type)
                {
                case UIFormType.Normal:
                    goClonePrefabs.transform.SetParent(_TraNormal, false);
                    break;

                case UIFormType.Fixed:
                    goClonePrefabs.transform.SetParent(_TraFixed, false);
                    break;

                case UIFormType.PopUp:
                    goClonePrefabs.transform.SetParent(_TraPopUp, false);
                    break;
                }

                goClonePrefabs.SetActive(false);

                _DicAllUIForms.Add(uiFormName, baseUIForm);
                return(baseUIForm);
            }
            else
            {
                Debug.LogError("UIRoot为空或者UIPrefab为空,参数uiFormName=" + uiFormName);
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 将当前窗体加载到“当前窗体”集合中
        /// </summary>
        /// <param name="uiForme">窗体预设名称</param>
        private void LoadUIToCurrentCache(string uiFormName)
        {
            BaseUIForm baseUIForm             = default(BaseUIForm);
            BaseUIForm baseUIFormFromAllCache = default(BaseUIForm);

            //如果“正在显示"的集合中,存在UI窗体,则直接返回
            _DicCurrentShowUIForms.TryGetValue(uiFormName, out baseUIForm);
            if (baseUIForm != null)
            {
                return;
            }
            //将当前窗体,加载到正在显示集合中
            _DicAllUIForms.TryGetValue(uiFormName, out baseUIFormFromAllCache);
            if (baseUIFormFromAllCache != null)
            {
                _DicCurrentShowUIForms.Add(uiFormName, baseUIFormFromAllCache);
                baseUIFormFromAllCache.Display();//显示当前窗体
            }
        }
Beispiel #4
0
        /// <summary>
        /// UI窗体入栈
        /// </summary>
        /// <param name="uiFormName">UI窗体名称</param>
        private void PushUIFormToStack(string uiFormName)
        {
            BaseUIForm baseUIForm;

            if (_StaCurrentUIForms.Count > 0)
            {
                BaseUIForm topUIForm = _StaCurrentUIForms.Peek();
                topUIForm.Freeze();
            }

            _DicAllUIForms.TryGetValue(uiFormName, out baseUIForm);

            if (baseUIForm != null)
            {
                baseUIForm.Display();
                _StaCurrentUIForms.Push(baseUIForm);
            }
            else
            {
                Debug.Log("baseUIForm==null,Please Check,Params uiFormName=" + uiFormName);
            }
        }