Пример #1
0
 void OnClose(UISystem uiSystem)
 {
     //调用界面的Close
     UIMod[] childrens = uiSystem.GetComponentsInChildren <UIMod>();
     for (int i = 0; i < childrens.Length; i++)
     {
         childrens[i].Close();
     }
     uiSystem.gameObject.SetActive(false);
     if (uiSystem.uiState == UIState.DESTROYONCLOSE)
     {
         UnloadUI(uiSystem);
     }
 }
Пример #2
0
    //负责显示UI
    void OnOpen(UISystem uiSystem)
    {
        //处理堆栈逻辑
        switch (uiSystem.stackLevel)
        {
        case StackLevel.AUTO:
            string oldUIName = null;
            if (_uiStack.Count > 0)
            {
                oldUIName = _uiStack.Peek();
            }

            if (uiSystem.uiName.Equals(oldUIName))    //打开已经销毁的栈顶界面会出现这种情况
            {
                break;
            }

            UIStackInfo stackInfo;
            if (!string.IsNullOrEmpty(oldUIName))
            {
                //关闭上一个Auto界面和相关的half界面
                UISystem oldSys = _UIListByName[oldUIName];
                StackRecord(oldSys);
                oldSys.gameObject.SetActive(false);
                stackInfo = _stackInfoDic[oldUIName];
                List <string> halfList;
                if (stackInfo.halfDicByIndex.TryGetValue(oldSys.stackIndex, out halfList))
                {
                    for (int i = 0; i < halfList.Count; i++)
                    {
                        UISystem halfSys = _UIListByName[halfList[i]];
                        StackRecord(halfSys);
                        halfSys.gameObject.SetActive(false);
                    }
                }
            }
            RecordStackID(uiSystem);
            //记录当前堆栈界面
            _uiStack.Push(uiSystem.uiName);
            if (!_stackInfoDic.ContainsKey(uiSystem.uiName))
            {
                stackInfo = PoolMgr.Inst.SpawnObj <UIStackInfo>();
                _stackInfoDic.Add(uiSystem.uiName, stackInfo);
            }
            break;

        case StackLevel.HALF:
            if (_uiStack.Count == 0)
            {
                Debug.LogErrorFormat("<UIMgr> 无法直接打开Half界面,必须要有一个已开启的Auto界面!");
                return;
            }
            string   uiName  = _uiStack.Peek();
            UISystem autoSys = _UIListByName[uiName];
            if (!autoSys.gameObject.activeSelf)
            {
                Debug.LogErrorFormat("<UIMgr> 无法直接打开Half界面,必须要有一个已开启的Auto界面!");
                return;
            }
            //注意:重新打开已经销毁的half界面,stackIndex会被修改掉
            stackInfo = _stackInfoDic[uiName];
            stackInfo.AddHalfUI(autoSys.stackIndex, uiSystem.uiName);
            RecordStackID(uiSystem);
            break;

        case StackLevel.Manual:
            break;
        }

        //调用界面的Open
        UIMod[] childrens = uiSystem.GetComponentsInChildren <UIMod>();
        for (int i = 0; i < childrens.Length; i++)
        {
            childrens[i].Open();
        }
    }