mirror of
https://gitee.com/nomat/lcc-ui-sorting-group-demo.git
synced 2024-12-25 11:18:28 +00:00
添加动态修改功能
This commit is contained in:
parent
3d26effa41
commit
70c4e8da16
@ -67,7 +67,7 @@ UI.prototype.flushRendererCache = function(){
|
||||
}
|
||||
// console.log(`flushRendererCache ${rendererCache.length}`);
|
||||
for(let render of rendererCache){
|
||||
// console.log(`${render.node.name} render hash ${render.renderData.dataHash}`);
|
||||
// console.log(`${render.node.name} render hash ${render.renderPriority}`);
|
||||
render.fillBuffers(this);
|
||||
if(render.renderOpacity >= 0){
|
||||
updateOpacity(render.renderData, render.renderOpacity);
|
||||
|
@ -12,13 +12,37 @@ export class SortingGroup extends Component {
|
||||
* 排序层
|
||||
*/
|
||||
@type(Enum(SortingLayer))
|
||||
sortingLayer:SortingLayer = SortingLayer.DEFAULT;
|
||||
private _sortingLayer:SortingLayer = SortingLayer.DEFAULT;
|
||||
|
||||
/**
|
||||
* 排序层
|
||||
*/
|
||||
@type(Enum(SortingLayer))
|
||||
get sortingLayer(){
|
||||
return this._sortingLayer;
|
||||
}
|
||||
set sortingLayer(value:SortingLayer){
|
||||
this._sortingLayer = value;
|
||||
this._uiTransform.sortingPriority = Math.sign(this._sortingLayer) * (Math.abs(this._sortingLayer) * ORDER_IN_LAYER_MAX + this._orderInLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
@property({ type:CCFloat, min: 0, max : ORDER_IN_LAYER_MAX })
|
||||
private _orderInLayer:number = 0;
|
||||
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
@property({ type:CCFloat, min: 0, max : ORDER_IN_LAYER_MAX })
|
||||
orderInLayer:number = 0;
|
||||
get orderInLayer(){
|
||||
return this._orderInLayer;
|
||||
}
|
||||
set orderInLayer(value:number){
|
||||
this._orderInLayer = value;
|
||||
this._uiTransform.sortingPriority = Math.sign(this._sortingLayer) * (Math.abs(this._sortingLayer) * ORDER_IN_LAYER_MAX + this._orderInLayer);
|
||||
}
|
||||
|
||||
private _uiTransform:UITransform = null;
|
||||
|
||||
@ -27,7 +51,7 @@ export class SortingGroup extends Component {
|
||||
}
|
||||
|
||||
onEnable(){
|
||||
this._uiTransform.sortingPriority = Math.sign(this.sortingLayer) * (Math.abs(this.sortingLayer) * ORDER_IN_LAYER_MAX + this.orderInLayer);
|
||||
this._uiTransform.sortingPriority = Math.sign(this._sortingLayer) * (Math.abs(this._sortingLayer) * ORDER_IN_LAYER_MAX + this._orderInLayer);
|
||||
this._uiTransform.sortingEnabled = true;
|
||||
}
|
||||
|
||||
|
@ -268,8 +268,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 9
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 6,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 6,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -368,8 +368,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 16
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 1,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 1,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -577,8 +577,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 25
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 7,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 7,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -677,8 +677,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 32
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 2,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 2,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -846,8 +846,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 42
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 3,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 3,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -1110,8 +1110,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 52
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 5,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 5,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -1234,8 +1234,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 61
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 4,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 4,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -1334,8 +1334,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 68
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 8,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 8,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -1485,8 +1485,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 76
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 9,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 9,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -1585,8 +1585,8 @@
|
||||
"__prefab": {
|
||||
"__id__": 83
|
||||
},
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 0,
|
||||
"_sortingLayer": 1,
|
||||
"_orderInLayer": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
@ -1032,8 +1032,8 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 3,
|
||||
"_sortingLayer": 0,
|
||||
"_orderInLayer": 0,
|
||||
"_id": "b7SyZGN8ZByo48B8plzxZd"
|
||||
},
|
||||
{
|
||||
@ -1276,8 +1276,8 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 2,
|
||||
"_sortingLayer": 0,
|
||||
"_orderInLayer": 0,
|
||||
"_id": "0fSX301tNL3ID+MhrxV/d7"
|
||||
},
|
||||
{
|
||||
@ -1681,8 +1681,8 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"sortingLayer": 1,
|
||||
"orderInLayer": 1,
|
||||
"_sortingLayer": 0,
|
||||
"_orderInLayer": 0,
|
||||
"_id": "e8pXnnkRRPfo50O0CR7SRu"
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user