From f0c5b423d69329df7ace9f6f9fddbe36f19f6319 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 27 May 2026 15:35:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=BB=84=E4=BB=B6=E8=B0=83=E8=AF=95=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8E=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 将CardLiteComp的debugMode默认值改为false 2. 修复heros预制体的Widget对齐参数与位置 3. 优化HerosListComp的日志调试开关,新增卡片列表内容高度自适应逻辑 --- assets/resources/gui/element/heros.prefab | 14 +++++----- assets/script/game/map/CardLiteComp.ts | 2 +- assets/script/game/map/HerosListComp.ts | 32 +++++++++++++++++++---- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/assets/resources/gui/element/heros.prefab b/assets/resources/gui/element/heros.prefab index df491f67..83211266 100644 --- a/assets/resources/gui/element/heros.prefab +++ b/assets/resources/gui/element/heros.prefab @@ -102,7 +102,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 0, + "y": 366, "z": 0 }, "_lrot": { @@ -212,16 +212,16 @@ "node": { "__id__": 2 }, - "_enabled": false, + "_enabled": true, "__prefab": { "__id__": 8 }, - "_alignFlags": 45, + "_alignFlags": 4, "_target": null, - "_left": 144, - "_right": 144, - "_top": 117, - "_bottom": 227, + "_left": -5, + "_right": -5, + "_top": -5, + "_bottom": 0, "_horizontalCenter": 0, "_verticalCenter": 0, "_isAbsLeft": true, diff --git a/assets/script/game/map/CardLiteComp.ts b/assets/script/game/map/CardLiteComp.ts index a606b1a0..602d8a35 100644 --- a/assets/script/game/map/CardLiteComp.ts +++ b/assets/script/game/map/CardLiteComp.ts @@ -39,7 +39,7 @@ const { ccclass, property } = _decorator; @ccclass('CardLiteComp') @ecs.register('CardLiteComp', false) export class CardLiteComp extends CCComp { - private debugMode: boolean = true; + private debugMode: boolean = false; // ======================== 编辑器绑定节点 ======================== diff --git a/assets/script/game/map/HerosListComp.ts b/assets/script/game/map/HerosListComp.ts index 4e826cbb..c0a2b116 100644 --- a/assets/script/game/map/HerosListComp.ts +++ b/assets/script/game/map/HerosListComp.ts @@ -17,7 +17,7 @@ * - CardLiteComp —— 轻量卡片组件 * - buildSkillDesc(HeroSkillDesc)—— 技能描述生成器 */ -import { _decorator, Animation, AnimationClip, Label, Node, Prefab, Sprite, Widget, instantiate, resources } from "cc"; +import { _decorator, Animation, AnimationClip, Label, Node, Prefab, Sprite, UITransform, Widget, instantiate, resources } 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 { oops } from "db://oops-framework/core/Oops"; @@ -89,7 +89,7 @@ export class HerosListComp extends CCComp { // ======================== 卡片列表 ======================== private initCardList() { - mLogger.log(true, "HerosListComp", "initCardList start", { + mLogger.log(this.debugMode, "HerosListComp", "initCardList start", { hasCardsNode: !!this.cards_node, hasPrefab: !!this.card_lite_prefab, heroListLen: HeroList.length, @@ -97,7 +97,7 @@ export class HerosListComp extends CCComp { if (!this.cards_node || !this.card_lite_prefab) return - mLogger.log(true, "HerosListComp", "cards_node info", { + mLogger.log(this.debugMode, "HerosListComp", "cards_node info", { name: this.cards_node.name, active: this.cards_node.active, childrenCount: this.cards_node.children.length, @@ -115,7 +115,7 @@ export class HerosListComp extends CCComp { const cardNode = instantiate(this.card_lite_prefab) cardNode.name = `card_${uuid}` - mLogger.log(true, "HerosListComp", `card instantiated ${uuid}`, { + mLogger.log(this.debugMode, "HerosListComp", `card instantiated ${uuid}`, { cardActive: cardNode.active, cardPos: cardNode.position.toString(), cardScale: cardNode.scale.toString(), @@ -134,9 +134,31 @@ export class HerosListComp extends CCComp { this.cards_node.addChild(cardNode) } - mLogger.log(true, "HerosListComp", "initCardList done", { + mLogger.log(this.debugMode, "HerosListComp", "initCardList done", { totalChildren: this.cards_node.children.length, }) + + this.updateContentSize() + } + + private updateContentSize() { + const total = this.cards_node.children.length + if (total === 0) return + + const cols = 4 + const rows = Math.ceil(total / cols) + const cardH = 200 + const spacingY = 10 + const contentH = Math.max(1000, rows * (cardH + spacingY) + 50) + + const uiTrans = this.cards_node.getComponent(UITransform) + if (uiTrans) { + uiTrans.setContentSize(uiTrans.width, contentH) + } + + mLogger.log(this.debugMode, "HerosListComp", "updateContentSize", { + total, cols, rows, contentH, + }) } private highlightCard(cardNode: Node) {