From 654dd405b9fa2718b3a400aa6f78fcc4b0a1b385 Mon Sep 17 00:00:00 2001 From: gongxh Date: Mon, 19 May 2025 11:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E9=85=8D=E7=BD=AEGa?= =?UTF-8?q?meEntiry=E4=B8=AD=E7=9A=84ecConfig=E6=97=B6=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ package.json | 2 +- src/cocos/CocosEntry.ts | 2 +- src/ecmodule/ECManager.ts | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fd4be5..dada950 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,3 +18,5 @@ - UI模块添加fgui控制器和动画装饰器,详情见 [UI模块](./docs/UI.md) ## 1.0.34 - 兼容性修改,兼容creator3.7及之后的版本 +## 1.0.35 +- 修复未配置GameEntiry中的ecConfig时报错的问题 diff --git a/package.json b/package.json index 4371cac..b983779 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kunpocc", - "version": "1.0.34", + "version": "1.0.35", "description": "基于creator3.0+的kunpocc库", "main": "./dist/kunpocc.cjs", "module": "./dist/kunpocc.mjs", diff --git a/src/cocos/CocosEntry.ts b/src/cocos/CocosEntry.ts index 3900334..ebb0fc1 100644 --- a/src/cocos/CocosEntry.ts +++ b/src/cocos/CocosEntry.ts @@ -48,7 +48,7 @@ export abstract class CocosEntry extends Component { director.addPersistRootNode(this.node); this.node.setSiblingIndex(this.node.children.length - 1); PropsHelper.setConfig(this.uiConfig?.json); - ECManager.registerEntityConfig(this.ecConfig?.json); + this.ecConfig && ECManager.registerEntityConfig(this.ecConfig.json); this.initPlatform(); this.initEvent(); this.initTime(); diff --git a/src/ecmodule/ECManager.ts b/src/ecmodule/ECManager.ts index 9c8c71b..6f15e36 100644 --- a/src/ecmodule/ECManager.ts +++ b/src/ecmodule/ECManager.ts @@ -86,6 +86,9 @@ export class ECManager { * @param config 实体配置信息,格式为 {实体名: {组件名: 组件数据}} */ public static registerEntityConfig(config: { [entityName: string]: IEntityConfig }): void { + if (!config) { + return; + } // 遍历并注册每个实体的配置 for (const entityName in config) { this._entityList[entityName] = config[entityName];