From 774a649bcdecfdcad16f6e17e162c2ed9ffffffc Mon Sep 17 00:00:00 2001 From: lujun <495904500@qq.com> Date: Tue, 21 Mar 2023 23:07:22 +0800 Subject: [PATCH] =?UTF-8?q?3.6.3=E8=8E=B7=E5=8F=96UITransfrom=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lcc-ui-sorting-group/sorting-group.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/3.6.3/assets/lcc-ui-sorting-group/sorting-group.ts b/3.6.3/assets/lcc-ui-sorting-group/sorting-group.ts index 9a2453b..20fbebe 100644 --- a/3.6.3/assets/lcc-ui-sorting-group/sorting-group.ts +++ b/3.6.3/assets/lcc-ui-sorting-group/sorting-group.ts @@ -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(){ - this._uiTransform = this.getComponent(UITransform); + /** + * 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; } }