fix(talents): 动态调整天赋列表容器高度
根据当前天赋配置数量重新计算列表容器高度,避免内容超出或留白过多,适配不同数量的天赋条目展示。
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user