From b9c3b75d5f2e41fe096998eb64b56e167fd6e05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=88=98?= <40414978+PatriceJiang@users.noreply.github.com> Date: Tue, 24 Nov 2020 17:14:28 +0800 Subject: [PATCH] TiledLayer should watch parent node position (#7857) --- cocos/tiledmap/tiled-layer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos/tiledmap/tiled-layer.ts b/cocos/tiledmap/tiled-layer.ts index 8ae73f65fd..eaba161599 100644 --- a/cocos/tiledmap/tiled-layer.ts +++ b/cocos/tiledmap/tiled-layer.ts @@ -390,13 +390,19 @@ export class TiledLayer extends UIRenderable { super.onEnable(); this.node.on(SystemEventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); this.node.on(SystemEventType.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.on(SystemEventType.SIZE_CHANGED, this.updateCulling, this); + this.node.parent!.on(SystemEventType.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.parent!.on(SystemEventType.SIZE_CHANGED, this.updateCulling, this); this.markForUpdateRenderData(); } onDisable () { super.onDisable(); - this.node.off(SystemEventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); + this.node.parent!.off(SystemEventType.SIZE_CHANGED, this.updateCulling, this); + this.node.parent!.off(SystemEventType.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.off(SystemEventType.SIZE_CHANGED, this.updateCulling, this); this.node.off(SystemEventType.TRANSFORM_CHANGED, this.updateCulling, this); + this.node.off(SystemEventType.ANCHOR_CHANGED, this._syncAnchorPoint, this); } protected _syncAnchorPoint () {