Esempio n. 1
0
        /// <summary>
        /// Calculate right depth with windowType
        /// </summary>
        /// <param name="baseWindow"></param>
        private void AdjustBaseWindowDepth(UIWindowBase baseWindow)
        {
            UIWindowType windowType = baseWindow.windowData.windowType;
            int          needDepth  = 1;

            if (windowType == UIWindowType.NormalLayer)
            {
                needDepth = Mathf.Clamp(UGUITools.GetMaxTargetDepth(UINormalLayerRoot.gameObject, false) + 1, normalWindowDepth, int.MaxValue);
                Debug.Log(string.Format("<color=#2a5caa>[UIWindowType.Normal] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString()));
            }
            else if (windowType == UIWindowType.ForegroundLayer)
            {
                needDepth = Mathf.Clamp(UGUITools.GetMaxTargetDepth(UIForegroundLayerRoot.gameObject) + 1, popUpWindowDepth, int.MaxValue);
                Debug.Log(string.Format("<color=#2a5caa>[UIWindowType.PopUp] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString()));
            }
            else if (windowType == UIWindowType.BackgroundLayer)
            {
                needDepth = Mathf.Clamp(UGUITools.GetMaxTargetDepth(UIBackgroundLayerRoot.gameObject) + 1, fixedWindowDepth, int.MaxValue);
                Debug.Log(string.Format("<color=#2a5caa>[UIWindowType.Fixed] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString()));
            }
            if (baseWindow.MinDepth != needDepth)
            {
                UGUITools.SetTargetMinPanelDepth(baseWindow.gameObject, needDepth);
            }

            // send window added message to game client
            if (baseWindow.windowData.windowType == UIWindowType.ForegroundLayer)
            {
                // trigger the window PopRoot added window event
                // EventDispatcher.GetInstance().UIFrameWorkEventManager.TriggerEvent(EventId.PopRootWindowAdded);
                //暂时不需要事件系统
            }
            baseWindow.MinDepth = needDepth;
        }
Esempio n. 2
0
        // Push target GameObject to top depth
        // Case: when you open multi PopWindow
        // You want one of these PopWindow stay at the Top
        // You can register the EventSystemDefine.EventUIFrameWorkPopRootWindowAdded
        // Call this method to push window to top
        public static void AdjustTargetWindowDepthToTop(UIWindowBase targetWindow)
        {
            if (targetWindow == null)
            {
                return;
            }

            Transform windowRoot = Instance.GetTargetRoot(targetWindow.windowData.windowType);
            int       needDepth  = Mathf.Clamp(UGUITools.GetMaxTargetDepth(windowRoot.gameObject, true) + 1, popUpWindowDepth, int.MaxValue);

            UGUITools.SetTargetMinPanelDepth(targetWindow.gameObject, needDepth);
            targetWindow.MinDepth = needDepth;
        }