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) => {