From 5583dca2b6046984fd77b75e828e3a408d525b72 Mon Sep 17 00:00:00 2001 From: panFD Date: Mon, 14 Sep 2026 17:09:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(hero=20view):=20=E6=B8=85=E7=90=86=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E8=8A=82=E7=82=B9=E6=AE=8B=E7=95=99=E7=89=B9=E6=95=88?= =?UTF-8?q?=E5=AD=90=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复对象池复用英雄节点时,残留上一个单位的特效到新单位的问题 --- assets/script/game/hero/HeroViewComp.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index be32345f..bd3762b4 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -544,6 +544,15 @@ export class HeroViewComp extends CCComp { // 清理残留的定时器和缓动 this.unscheduleAllCallbacks(); Tween.stopAllByTarget(this.node); + // 清理挂在节点下未播完的特效子节点(冰冻/击晕/受击等), + // 防止对象池复用节点时把上一个单位的特效带到新单位身上。 + // 判定依据:特效由 spawnTimedFx/spawnAnimEndFx 实例化并挂 timedCom/oneCom, + // 预制体自带子节点(anm/top 等)无这两个组件,不受影响。 + for (const child of [...this.node.children]) { + if (child.getComponent(timedCom) || child.getComponent(oneCom)) { + child.destroy(); + } + } this.topBar.reset(); // 清理碰撞器事件监听