From 7340ce2c24fde398dd7b75e711633a451cce057c Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 17 Dec 2024 10:40:28 +0800 Subject: [PATCH] Fix that the reparented items outside mask clip rect still could be touched. (#18039) --- cocos/scene-graph/node-event-processor.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cocos/scene-graph/node-event-processor.ts b/cocos/scene-graph/node-event-processor.ts index da4c3875535..5dae5eb9ec3 100644 --- a/cocos/scene-graph/node-event-processor.ts +++ b/cocos/scene-graph/node-event-processor.ts @@ -169,12 +169,11 @@ export class NodeEventProcessor { } public reattach (): void { - let currentMaskList: IMask[] | null; this.node.walk((node) => { - if (!currentMaskList) { - currentMaskList = this._searchComponentsInParent(NodeEventProcessor._maskComp); - } - node.eventProcessor.maskList = currentMaskList; + const eventProcessor = node.eventProcessor; + // NOTE: When reattaching the current node, the masks of all its descendants need to be recalculated + const currentMaskList = eventProcessor._searchComponentsInParent(NodeEventProcessor._maskComp); + eventProcessor.maskList = currentMaskList; }); }