示例#1
0
        /// <summary>
        /// 打开UI
        /// </summary>
        /// <param name="uiPrefabName">UI预制体名</param>
        /// <returns></returns>
        public UIComponentBase OpenUI(string uiPrefabName)
        {
            UIComponentBase currUI;

            if (!_uiMainPool.TryGetValue(uiPrefabName, out currUI))
            {
                currUI = CreateOrGetUI(uiPrefabName);
                if (currUI != null)
                {
                    foreach (var relationalUIName in currUI.Data.RelationalUINames)
                    {
                        currUI.AddRelationalUI(CreateOrGetUI(relationalUIName));
                    }
                }
            }

            if (currUI != null)
            {
                // 取得上一层UI信息
                if (0 < this._uiShowStack.Count)
                {
                    UIComponentBase lastUI = null;
                    if (false == currUI.IsOverlapping)
                    {
                        lastUI = this._uiShowStack.Peek();
                        if (null != lastUI)
                        {
                            lastUI.Close();
                        }
                    }
                    // 替换UI的场合,把顶层所有Popup的UI移除后,在关闭上一UI
                    if (true == currUI.IsSwap)
                    {
                        while (true)
                        {
                            lastUI = this._uiShowStack.Peek();
                            if (null == lastUI)
                            {
                                break;
                            }
                            if (false == lastUI.IsOverlapping)
                            {
                                break;
                            }
                            lastUI = this._uiShowStack.Pop();
                            lastUI.Close();
                        }
                        if (null != lastUI)
                        {
                            lastUI.Close();
                        }
                    }
                }

                // 将新加载UI放入UI显示堆
                _uiShowStack.Push(currUI);
                currUI.Open();
            }
            return(currUI);
        }
示例#2
0
        /// <summary>
        /// 返回.
        /// </summary>
        /// <returns><c>true</c>, 返回成功, <c>false</c> 无上一步可返回/无需返回.</returns>
        private bool InnerBackUI()
        {
            if (0 < this._uiShowStack.Count)
            {
                UIComponentBase currUI = this._uiShowStack.Peek();
                if (null == currUI)
                {
                    return(false);
                }
                if (false == currUI.IsBackAble)
                {
                    return(false);
                }
                currUI = this._uiShowStack.Pop();
                if (null == currUI)
                {
                    return(false);
                }
                currUI.Close();

                // 替换的场合,回复上一个UI
                if (true == currUI.IsSwap)
                {
                    currUI = this._uiShowStack.Peek();
                    currUI.Open();
                }

                return(true);
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// 关闭UI(不包含指定预制体)
        /// </summary>
        /// <param name="uiPrefabName">UI预制体名.</param>
        public void CloseUITo(string uiPrefabName)
        {
            if (string.IsNullOrEmpty(uiPrefabName))
            {
                this.Warning("CloseUI():The prefab name is invalid!!");
                return;
            }

            if (0 >= this._uiShowStack.Count)
            {
                this.Warning("CloseUI():There is no ui left in ui show stack!!");
                return;
            }
            UIComponentBase currUI = null;

            while (true)
            {
                // 推出UI显示栈
                currUI = this._uiShowStack.Peek();
                if (null == currUI)
                {
                    break;
                }
                if (true == uiPrefabName.Equals(currUI.name))
                {
                    currUI.Open();
                    break;
                }
                currUI = this._uiShowStack.Pop();
                currUI.Close();
            }
        }
示例#4
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        public void CloseUI()
        {
            if (0 >= this._uiShowStack.Count)
            {
                this.Warning("CloseUI():There is no ui left in ui show stack!!");
                return;
            }
            // 推出UI显示栈
            UIComponentBase currUI = this._uiShowStack.Pop();

            // 推出UI显示栈
            if (null != currUI)
            {
                currUI.Close();
                // 替换的场合,重新打开上一个UI
                if (true == currUI.IsSwap)
                {
                    UIComponentBase _lastInfo = this._uiShowStack.Peek();
                    if (null != _lastInfo)
                    {
                        _lastInfo.Open();
                    }
                }
            }
        }