修复ECSEntity释放时,未自动释放子ECSEntity的问题

This commit is contained in:
dgflash
2022-08-09 16:52:36 +08:00
parent 3f45644fde
commit 1b3192f583

View File

@@ -251,10 +251,14 @@ export class ECSEntity {
this.remove(comp, false);
}
/**
* 销毁实体,实体会被回收到实体缓存池中。
*/
/** 销毁实体,实体会被回收到实体缓存池中 */
destroy() {
if (this._children) {
this._children.forEach(e => {
e.destroy();
});
}
this.compTid2Ctor.forEach(this._remove, this);
destroyEntity(this);
this.compTid2Obj.clear();