Exemple #1
0
        protected override void PostSetVisible(bool _bVisible)
        {
            if (m_wndView == null)
            {
                return;
            }

            if (_bVisible)
            {
                //有全屏窗口显示中并当前WND_LAYER_POPUP01类型窗口需要显示时,将其提升到WND_LAYER_POPUP02层进行显示
                if (GetLayer() == WndLayerDef.WND_LAYER_POPUP01)
                {
                    UISystem.Instance.SetWndRenderAfterTheFillLayer(m_wndView, WndLayerDef.WND_LAYER_POPUP02);
                }
                //Popup类型显示时顶置
                if ((GetLayer() == WndLayerDef.WND_LAYER_POPUP01 || GetLayer() == WndLayerDef.WND_LAYER_POPUP02))
                {
                    UISystem.Instance.SetMutexWndVisbleAlone(this.m_wndView, WndLayerDef.WND_LAYER_POPUP01, WndLayerDef.WND_LAYER_FILL, WndLayerDef.WND_LAYER_POPUP02);

                    if (m_wndView.GetTransform() != null)
                    {
                        m_wndView.GetTransform().SetAsLastSibling();

                        //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                        //StringBuilder sb = new StringBuilder();
                        //watch.Start();

                        //重新算该层级下所有界面的层级数
                        USpeedUILayer layer = USpeedUILayerManager.GetUILayer(GetLayer());
                        if (layer != null)
                        {
                            RectTransform LayerTrans = layer.GetRectTransform;
                            if (LayerTrans != null)
                            {
                                int count = LayerTrans.childCount;
                                for (int i = 0; i < count; ++i)
                                {
                                    USpeedUILayerElement element = LayerTrans.GetChild(i).GetComponent <USpeedUILayerElement>();
                                    if (element != null)
                                    {
                                        LayerTrans.GetChild(i).GetComponent <USpeedUILayerElement>().SetSortingOrder();
                                    }
                                }
                            }
                        }
                    }

                    //watch.Stop();
                    //sb.Append(m_wndView.gameObject.name + " time:" + watch.Elapsed.TotalMilliseconds);
                    //Debug.LogWarning(sb.ToString());
                }
            }
            else
            {
                UISystem.Instance.RemoveWndRenderAfterFillLayerVisible(this);
                //隐藏的时候还原回原来的层
                UISystem.Instance.AddView(m_wndView, GetLayer());
            }
        }
Exemple #2
0
 protected override void OnEnable()
 {
     targetUILayerElement = target as USpeedUILayerElement;
     if (targetUILayerElement)
     {
         targetUILayerElement.RegisterUIElement();
     }
 }
Exemple #3
0
        public static void UnRegisterElementForLayer(USpeedUILayer _nLayer, USpeedUILayerElement _nElement)
        {
            if (_nLayer == null)
            {
                return;
            }

            List <USpeedUILayerElement> layerElements;

            if (instance.m_DicLayerElememt.TryGetValue(_nLayer, out layerElements))
            {
                layerElements.Remove(_nElement);
            }
        }
Exemple #4
0
        /// <summary>
        /// USpeedUILayerElement(层级元素)计算公式
        /// 1、if( USpeedUILayerElement.gameobject has IUIWndView)
        ///     USpeedUILayerElement 在父节点下的对象层级顺序 * LayerElementSiblingIndexDelta + LayerElementSiblingIndexDelta;
        /// 2、else
        ///     USpeedUILayerElement.wndViewLayerOrder(element所在的View 层级) + USpeedUILayerElement.SortingLayerOrderOffset (element 层级偏移系数)
        ///     + USpeedUILayerElement.SortingLayrOrderParentOffset(element 所有带 USpeedUILayerElement 的父对象层级偏移数)
        ///     + USpeedUILayerElement.SortingLayerSiblingIndex (在父节点下的对象层级顺序 ) * LayerElementSiblingIndexDelta(增量系数);
        /// </summary>
        /// <param name="_nElement"></param>
        /// <returns></returns>
        public static int CalculateLayerElementOrder(USpeedUILayerElement _nElement)
        {
            if (_nElement.UIWndView == null || _nElement.UIWndView.GetTransform() == null || _nElement.UIWndView.GetTransform().GetComponent <Canvas>() == null)
            {
                return(_nElement.SortingLayerOrderOffset);
            }

            if (Transform.Equals(_nElement.UIWndView.GetTransform(), _nElement.GetTransform))
            {
                //当前element 是View
                return(CalculateWndViewLayerOrder(_nElement.GetComponent <IUIWndView>()));
                //return _nElement.SortingLayerSiblingIndex * LayerElementSiblingIndexDelta + LayerElementSiblingIndexDelta;
            }
            else
            {
                int viewLayer = _nElement.UIWndView.GetTransform().GetComponent <Canvas>().sortingOrder;
                return(viewLayer + _nElement.SortingLayerOrderOffset + _nElement.SortingLayrOrderParentOffset +
                       _nElement.SortingLayerSiblingIndex * LayerElementSiblingIndexDelta);
            }
        }
Exemple #5
0
        public static void RegisterElementForLayer(USpeedUILayer _nLayer, USpeedUILayerElement _nElement)
        {
            if (_nLayer == null)
            {
                if (!instance.m_ListRegistrationFailed.Contains(_nElement))
                {
                    instance.m_ListRegistrationFailed.Add(_nElement);
                }
                return;
            }

            List <USpeedUILayerElement> layerElements;

            instance.m_DicLayerElememt.TryGetValue(_nLayer, out layerElements);

            if (layerElements != null)
            {
                if (!layerElements.Contains(_nElement))
                {
                    layerElements.Add(_nElement);
                }
            }
            else
            {
                layerElements = new List <USpeedUILayerElement>();
                layerElements.Add(_nElement);
                instance.m_DicLayerElememt.Add(_nLayer, layerElements);
            }

            //重新调整canvas的Sorting信息

            //调整SortingLayer,目前都统一用一个Layer,layer多的话会影响渲染效率
            _nElement.SortingLayerName = _nLayer.LayerCanvas.sortingLayerName;
            //调整SortingOrder
            _nElement.SortingLayerOrder = _nLayer.LayerCanvas.sortingOrder;

            if (instance.m_ListRegistrationFailed.Contains(_nElement) && _nLayer.LayerCanvas.sortingOrder != 0)
            {
                instance.m_ListRegistrationFailed.Remove(_nElement);
            }
        }
Exemple #6
0
        public static void RegisterWndViewForLayer(IUIWndView _uView)
        {
            if (_uView.GetTransform() == null || _uView.GetUIWnd() == null)
            {
                return;
            }
            USpeedUILayerElement viewLayerElement = _uView.GetTransform().GetComponent <USpeedUILayerElement>() ?? _uView.GetTransform().gameObject.AddComponent <USpeedUILayerElement>();

            viewLayerElement.UILayerElementType  = USpeedUILayerElement.EUILayerElementType.ELET_UI;
            viewLayerElement.IsUIRequirRaycaster = true;

            //重新调整canvas的Sorting信息
            //viewLayerElement = true;

            //调整SortingLayer,目前都统一用一个Layer,layer多的话会影响渲染效率
            viewLayerElement.SortingLayerName = CalculateLayerName(_uView.GetUIWnd().GetLayer());
            //调整SortingOrder
            viewLayerElement.SortingLayerOrder = CheckSortingOrderRange(CalculateWndViewLayerOrder(_uView));

            //计算Layer的Z轴坐标 layerDef越大,越靠近相机
            //Vector3 tmpPos = _nLayer.GetTransform.localPosition;
            //tmpPos.z = ((int)WndLayerDef.WND_LAYER_MAX - (int)_nLayerDef) * LayerZAxisDistance;
            //_nLayer.GetTransform.localPosition = tmpPos;
        }
Exemple #7
0
        public override void OnInspectorGUI()
        {
            targetUILayerElement = target as USpeedUILayerElement;
            EditorGUIUtils.SetGUIStyles();
            if (targetUILayerElement != null)
            {
                targetUILayerElement.SetSortingOrder();

                EditorGUILayout.Space();
                targetUILayerElement.UILayerElementType = (USpeedUILayerElement.EUILayerElementType)EditorGUILayout.EnumPopup("类型:", targetUILayerElement.UILayerElementType);
                switch (targetUILayerElement.UILayerElementType)
                {
                case USpeedUILayerElement.EUILayerElementType.ELET_UI:
                    OnInspectorGUI_UI();
                    break;

                case USpeedUILayerElement.EUILayerElementType.ELET_Effect:
                    OnInspectorGUI_Effect();
                    break;

                default:
                    break;
                }

                EditorGUILayout.Space();

                DrawSortingLayer();

                EditorGUILayout.Space();
                if (GUILayout.Button("编辑模式下移动到其他Layer时点下我"))
                {
                    targetUILayerElement.TransformParentChanged();
                }
                EditorGUILayout.Space();
            }
        }