diff --git a/assets/libs/ecs/ECSEntity.ts b/assets/libs/ecs/ECSEntity.ts index 3b1a22c..2879d61 100644 --- a/assets/libs/ecs/ECSEntity.ts +++ b/assets/libs/ecs/ECSEntity.ts @@ -96,13 +96,15 @@ export class ECSEntity { /** * 移除子实体 - * @param entity 被移除的实体对象 + * @param entity 被移除的实体对象 + * @param isDestroy 被移除的实体是否释放,默认为释放 * @returns */ - removeChild(entity: ECSEntity) { + removeChild(entity: ECSEntity, isDestroy = true) { if (this.children == null) return; this.children.delete(entity.eid); + if (isDestroy) entity.destroy(); if (this.children.size == 0) { this._children = null; diff --git a/assets/module/common/GameComponent.ts b/assets/module/common/GameComponent.ts index a122b5e..1d3d99e 100644 --- a/assets/module/common/GameComponent.ts +++ b/assets/module/common/GameComponent.ts @@ -370,7 +370,7 @@ export class GameComponent extends Component { for (const name of args) { var func = self[name]; if (func) - this.on(name, self[name], this); + this.on(name, func, this); else console.error(`名为【${name}】的全局事方法不存在`); }