3.6.3获取UITransfrom问题

This commit is contained in:
lujun 2023-03-21 23:07:22 +08:00
parent b27ec37d0c
commit 774a649bcd

View File

@ -23,7 +23,7 @@ export class SortingGroup extends Component {
}
set sortingLayer(value:SortingLayer){
this._sortingLayer = value;
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);
}
/**
@ -41,22 +41,31 @@ export class SortingGroup extends Component {
}
set orderInLayer(value:number){
this._orderInLayer = value;
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);
}
/**
* UITransform
*/
private _uiTransform:UITransform = null;
onLoad(){
/**
* UITransform
*/
get uiTransform(){
if(this._uiTransform == null){
this._uiTransform = this.getComponent(UITransform);
}
return this._uiTransform;
}
onEnable(){
this._uiTransform.sortingPriority = Math.sign(this._sortingLayer) * (Math.abs(this._sortingLayer) * ORDER_IN_LAYER_MAX + this._orderInLayer);
this._uiTransform.sortingEnabled = true;
this.uiTransform.sortingPriority = Math.sign(this._sortingLayer) * (Math.abs(this._sortingLayer) * ORDER_IN_LAYER_MAX + this._orderInLayer);
this.uiTransform.sortingEnabled = true;
}
onDisable(){
this._uiTransform.sortingPriority = 0;
this._uiTransform.sortingEnabled = false;
this.uiTransform.sortingPriority = 0;
this.uiTransform.sortingEnabled = false;
}
}