This commit is contained in:
lujun 2023-02-05 22:15:34 +08:00
parent f96e05fa43
commit c4bce47c1b
3 changed files with 10 additions and 4 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}
}