diff --git a/assets/lcc-ui-sorting-group/engine-extend.ts b/assets/lcc-ui-sorting-group/engine-extend.ts index ca8545e..ff626cc 100644 --- a/assets/lcc-ui-sorting-group/engine-extend.ts +++ b/assets/lcc-ui-sorting-group/engine-extend.ts @@ -1,5 +1,6 @@ import { clamp, gfx,Node,RenderData,UI,StencilManager,UIRenderer } from 'cc'; import { JSB } from 'cc/env'; +import { DEFAULT_SORTING_PRIORITY } from './sorting-define'; declare module 'cc' { interface UIRenderer { @@ -177,8 +178,8 @@ UI.prototype.walk = function(node: Node, level = 0){ } }else{ this.rendererCache.push(render); - render.sortingPriority = render.sortingPriority ?? 0; - if(render.sortingPriority != 0){ + render.sortingPriority = render.sortingPriority ?? DEFAULT_SORTING_PRIORITY; + if(render.sortingPriority != DEFAULT_SORTING_PRIORITY){ this.rendererOrder = true; } if (this._opacityDirty && render && !render.useVertexOpacity && render.renderData && render.renderData.vertexCount > 0) { diff --git a/assets/lcc-ui-sorting-group/sorting-define.ts b/assets/lcc-ui-sorting-group/sorting-define.ts index 12948ea..36cd199 100644 --- a/assets/lcc-ui-sorting-group/sorting-define.ts +++ b/assets/lcc-ui-sorting-group/sorting-define.ts @@ -21,3 +21,8 @@ export enum SortingLayer { * 在层级中最大排序值 */ export const ORDER_IN_LAYER_MAX = 100000; + +/** + * 默认排序优先级 + */ +export const DEFAULT_SORTING_PRIORITY = SortingLayer.DEFAULT * ORDER_IN_LAYER_MAX; diff --git a/assets/lcc-ui-sorting-group/sorting-group.ts b/assets/lcc-ui-sorting-group/sorting-group.ts index 7aa3210..688f623 100644 --- a/assets/lcc-ui-sorting-group/sorting-group.ts +++ b/assets/lcc-ui-sorting-group/sorting-group.ts @@ -1,6 +1,6 @@ import { _decorator, Component, Node, ccenum, CCInteger, CCFloat, Enum, director, UI, UIRenderer } from 'cc'; -import { ORDER_IN_LAYER_MAX, SortingLayer } from './sorting-define'; +import { DEFAULT_SORTING_PRIORITY, ORDER_IN_LAYER_MAX, SortingLayer } from './sorting-define'; const { ccclass, property, type, disallowMultiple, requireComponent } = _decorator; @ccclass('lcc-ui/SortingGroup') @@ -33,6 +33,6 @@ export class SortingGroup extends Component { } onDisable(){ - this._uiRenderer.sortingPriority = SortingLayer.DEFAULT * ORDER_IN_LAYER_MAX; + this._uiRenderer.sortingPriority = DEFAULT_SORTING_PRIORITY; } }