예제 #1
0
 private void DrawSortingLayer()
 {
     targetUILayerElement.IsUseSortingLayerOffset = EditorGUILayout.Toggle("是否设置层级偏移值", targetUILayerElement.IsUseSortingLayerOffset);
     if (targetUILayerElement.IsUseSortingLayerOffset)
     {
         EditorGUILayout.Space();
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("-"))
         {
             targetUILayerElement.SortingLayerOrderOffset--;
         }
         GUILayout.Label(targetUILayerElement.SortingLayerOrderOffset.ToString(), EditorGUIUtils.wrapCenterLabelStyle);
         if (GUILayout.Button("+"))
         {
             targetUILayerElement.SortingLayerOrderOffset++;
         }
         if (GUILayout.Button("归零"))
         {
             targetUILayerElement.SortingLayerOrderOffset = 0;
         }
         GUILayout.EndHorizontal();
         EditorGUILayout.LabelField("当前所在Layer的序号:", USpeedUILayerManager.CalculateLayerElementOrder(targetUILayerElement).ToString());
         //(targetUILayerElement.SortingLayerOrder + targetUILayerElement.SortingLayerOrderOffset + targetUILayerElement.SortingLayrOrderParentOffset).ToString());
     }
     else
     {
         //if((targetUILayerElement.SortingLayerOrder + targetUILayerElement.SortingLayerOrderOffset + targetUILayerElement.SortingLayrOrderParentOffset > 0))
         if (USpeedUILayerManager.CalculateLayerElementOrder(targetUILayerElement) > 0)
         {
             targetUILayerElement.SortingLayerOrder       = 0;
             targetUILayerElement.SortingLayerOrderOffset = 0;
         }
     }
 }
예제 #2
0
        public void SetSortingOrder()
        {
            if (!IsUseSortingLayerOffset)
            {
                return;
            }

            int _nNewOrder = USpeedUILayerManager.CalculateLayerElementOrder(this);//SortingLayerOrder + SortingLayerOrderOffset + SortingLayrOrderParentOffset;

            switch (UILayerElementType)
            {
            case EUILayerElementType.ELET_UI:
                SetSortingOrder_UI(_nNewOrder);
                break;

            case EUILayerElementType.ELET_Effect:
                SetSortingOrder_Effect(_nNewOrder);
                break;

            default:
                break;
            }
            //Debug.LogWarning("注册UIElement:" + this.gameObject.name + ",层级为:" + _nNewOrder);
        }