From f62b5ecc2b6aec1cad1dc080b47ab9f38d5d0e87 Mon Sep 17 00:00:00 2001 From: pan Date: Tue, 9 Jun 2026 10:15:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(talents):=20=E5=8A=A8=E6=80=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=A4=A9=E8=B5=8B=E5=88=97=E8=A1=A8=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据当前天赋配置数量重新计算列表容器高度,避免内容超出或留白过多,适配不同数量的天赋条目展示。 --- assets/script/game/map/TalentsComp.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/assets/script/game/map/TalentsComp.ts b/assets/script/game/map/TalentsComp.ts index aee678d5..b534e1c0 100644 --- a/assets/script/game/map/TalentsComp.ts +++ b/assets/script/game/map/TalentsComp.ts @@ -11,7 +11,7 @@ * - CardPoolList(CardSet)—— 获取技能卡配置 * - TalentItemComp —— 单条天赋图鉴项视图 */ -import { _decorator, instantiate, Node, Prefab } from "cc"; +import { _decorator, instantiate, Node, Prefab, UITransform } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { mLogger } from "../common/Logger"; @@ -68,6 +68,17 @@ export class TalentsComp extends CCComp { } }); this.rendered = true; + + // 动态调整容器高度 + // 默认底高 1000,每行 3 个天赋信息卡,每张卡高 270,行间距 15 + const totalCount = this.cachedConfigs.length; + const rows = Math.ceil(totalCount / 3); + const contentHeight = Math.max(1000, rows * 270 + (rows > 0 ? (rows - 1) * 15 : 0+50)); + + const uiTransform = this.talents_content.getComponent(UITransform); + if (uiTransform) { + uiTransform.height = contentHeight; + } } else { // 如果已渲染,则仅更新数据(图鉴一般不会变动,这里做个兜底更新) this.cachedConfigs.forEach((cfg, index) => {