From 469e6520445101f78ff4457319e4ca53fef510f7 Mon Sep 17 00:00:00 2001 From: humingxing <930621236@qq.com> Date: Fri, 16 Oct 2026 19:14:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BattleWeaponDesc1/UIBattleWeaponDesc1.ts | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/assets/script/ui/BattleWeaponDesc1/UIBattleWeaponDesc1.ts b/assets/script/ui/BattleWeaponDesc1/UIBattleWeaponDesc1.ts index 381522f..de33ded 100644 --- a/assets/script/ui/BattleWeaponDesc1/UIBattleWeaponDesc1.ts +++ b/assets/script/ui/BattleWeaponDesc1/UIBattleWeaponDesc1.ts @@ -228,6 +228,8 @@ export class UIBattleWeaponDesc1 extends Auto_BattleWeaponDesc1 { resolve(true); return; } + // 须在 prepareDestroyForRender 之前回池:否则 Sprite/Skeleton 被关掉再入池,下次出池图标空白 + this._clearGlyphNode(); this.prepareDestroyForRender(); if (this.node.isValid) { this.node.destroy(); @@ -307,16 +309,24 @@ export class UIBattleWeaponDesc1 extends Auto_BattleWeaponDesc1 { private _clearGlyphNode(): void { const held = this._glyphNode; this._glyphNode = null; + const fromPool = this._glyphFromPool; + this._glyphFromPool = false; if (held?.isValid) { - if (this._glyphFromPool) { + if (fromPool) { gg.res.putNode(held); } else { held.destroy(); } } - this._glyphFromPool = false; - if (this.ui_node?.isValid) { - this.ui_node.removeAllChildren(); + // 勿 removeAllChildren:池节点若尚未摘父会被destroy,污染对象池 + if (this.ui_node?.isValid && this.ui_node.children.length > 0) { + const left = this.ui_node.children.slice(); + for (let i = 0; i < left.length; i++) { + const c = left[i]; + if (!c?.isValid || c === held) continue; + if (c['resKey']) gg.res.putNode(c); + else c.destroy(); + } } } @@ -420,6 +430,8 @@ export class UIBattleWeaponDesc1 extends Auto_BattleWeaponDesc1 { this.ui_node.active = false; return; } + // 关页 prepareDestroy 会关 Sprite;出池须重新打开渲染(getNode 只恢复 Skeleton) + this._revivePooledGlyphRenderers(node); node.parent = this.ui_node; node.setPosition(0, 0, 0); node.setScale(GLYPH_SCALE, GLYPH_SCALE, 1); @@ -429,6 +441,25 @@ export class UIBattleWeaponDesc1 extends Auto_BattleWeaponDesc1 { this.ui_node.active = true; } + /** + * 恢复池节点上被关掉的 Sprite / Skeleton。 + * @param node 出池的卡面预制体 + */ + private _revivePooledGlyphRenderers(node: Node): void { + const renderers = node.getComponentsInChildren(UIRenderer); + for (let i = 0; i < renderers.length; i++) { + const r = renderers[i]; + if (r?.isValid) r.enabled = true; + } + const sks = node.getComponentsInChildren(sp.Skeleton); + for (let i = 0; i < sks.length; i++) { + const sk = sks[i]; + if (!sk?.isValid) continue; + sk.enabled = true; + sk.setAnimationCacheMode(sp.SpineAnimationCacheMode.REALTIME); + } + } + /** 解析 Hero 行(部署快照缺失时按 weapon1Id / 蟠桃 id 兜底) */ private _resolveHero(entity: TileEntitySnapshot): ITableHero | null { const fromTower = entity.tower?.config ?? null;