修复未配置GameEntiry中的ecConfig时报错的问题

This commit is contained in:
gongxh 2025-05-19 11:19:35 +08:00
parent 17d3cc968e
commit 654dd405b9
4 changed files with 7 additions and 2 deletions

View File

@ -18,3 +18,5 @@
- UI模块添加fgui控制器和动画装饰器详情见 [UI模块](./docs/UI.md) - UI模块添加fgui控制器和动画装饰器详情见 [UI模块](./docs/UI.md)
## 1.0.34 ## 1.0.34
- 兼容性修改兼容creator3.7及之后的版本 - 兼容性修改兼容creator3.7及之后的版本
## 1.0.35
- 修复未配置GameEntiry中的ecConfig时报错的问题

View File

@ -1,6 +1,6 @@
{ {
"name": "kunpocc", "name": "kunpocc",
"version": "1.0.34", "version": "1.0.35",
"description": "基于creator3.0+的kunpocc库", "description": "基于creator3.0+的kunpocc库",
"main": "./dist/kunpocc.cjs", "main": "./dist/kunpocc.cjs",
"module": "./dist/kunpocc.mjs", "module": "./dist/kunpocc.mjs",

View File

@ -48,7 +48,7 @@ export abstract class CocosEntry extends Component {
director.addPersistRootNode(this.node); director.addPersistRootNode(this.node);
this.node.setSiblingIndex(this.node.children.length - 1); this.node.setSiblingIndex(this.node.children.length - 1);
PropsHelper.setConfig(this.uiConfig?.json); PropsHelper.setConfig(this.uiConfig?.json);
ECManager.registerEntityConfig(this.ecConfig?.json); this.ecConfig && ECManager.registerEntityConfig(this.ecConfig.json);
this.initPlatform(); this.initPlatform();
this.initEvent(); this.initEvent();
this.initTime(); this.initTime();

View File

@ -86,6 +86,9 @@ export class ECManager {
* @param config {: {组件名: 组件数据}} * @param config {: {组件名: 组件数据}}
*/ */
public static registerEntityConfig(config: { [entityName: string]: IEntityConfig }): void { public static registerEntityConfig(config: { [entityName: string]: IEntityConfig }): void {
if (!config) {
return;
}
// 遍历并注册每个实体的配置 // 遍历并注册每个实体的配置
for (const entityName in config) { for (const entityName in config) {
this._entityList[entityName] = config[entityName]; this._entityList[entityName] = config[entityName];