mirror of
https://gitee.com/nomat/lcc-ui-sorting-group-demo.git
synced 2024-12-26 03:38:27 +00:00
日常
This commit is contained in:
parent
f96e05fa43
commit
c4bce47c1b
@ -1,5 +1,6 @@
|
|||||||
import { clamp, gfx,Node,RenderData,UI,StencilManager,UIRenderer } from 'cc';
|
import { clamp, gfx,Node,RenderData,UI,StencilManager,UIRenderer } from 'cc';
|
||||||
import { JSB } from 'cc/env';
|
import { JSB } from 'cc/env';
|
||||||
|
import { DEFAULT_SORTING_PRIORITY } from './sorting-define';
|
||||||
|
|
||||||
declare module 'cc' {
|
declare module 'cc' {
|
||||||
interface UIRenderer {
|
interface UIRenderer {
|
||||||
@ -177,8 +178,8 @@ UI.prototype.walk = function(node: Node, level = 0){
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
this.rendererCache.push(render);
|
this.rendererCache.push(render);
|
||||||
render.sortingPriority = render.sortingPriority ?? 0;
|
render.sortingPriority = render.sortingPriority ?? DEFAULT_SORTING_PRIORITY;
|
||||||
if(render.sortingPriority != 0){
|
if(render.sortingPriority != DEFAULT_SORTING_PRIORITY){
|
||||||
this.rendererOrder = true;
|
this.rendererOrder = true;
|
||||||
}
|
}
|
||||||
if (this._opacityDirty && render && !render.useVertexOpacity && render.renderData && render.renderData.vertexCount > 0) {
|
if (this._opacityDirty && render && !render.useVertexOpacity && render.renderData && render.renderData.vertexCount > 0) {
|
||||||
|
@ -21,3 +21,8 @@ export enum SortingLayer {
|
|||||||
* 在层级中最大排序值
|
* 在层级中最大排序值
|
||||||
*/
|
*/
|
||||||
export const ORDER_IN_LAYER_MAX = 100000;
|
export const ORDER_IN_LAYER_MAX = 100000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认排序优先级
|
||||||
|
*/
|
||||||
|
export const DEFAULT_SORTING_PRIORITY = SortingLayer.DEFAULT * ORDER_IN_LAYER_MAX;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import { _decorator, Component, Node, ccenum, CCInteger, CCFloat, Enum, director, UI, UIRenderer } from 'cc';
|
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;
|
const { ccclass, property, type, disallowMultiple, requireComponent } = _decorator;
|
||||||
|
|
||||||
@ccclass('lcc-ui/SortingGroup')
|
@ccclass('lcc-ui/SortingGroup')
|
||||||
@ -33,6 +33,6 @@ export class SortingGroup extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDisable(){
|
onDisable(){
|
||||||
this._uiRenderer.sortingPriority = SortingLayer.DEFAULT * ORDER_IN_LAYER_MAX;
|
this._uiRenderer.sortingPriority = DEFAULT_SORTING_PRIORITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user