|
|
@@ -450,30 +450,6 @@ namespace ET
|
|
|
this.IsRegister = false;
|
|
|
this.InstanceId = 0;
|
|
|
|
|
|
- // 清理Component
|
|
|
- if (this.components != null)
|
|
|
- {
|
|
|
- foreach (KeyValuePair<Type, Entity> kv in this.components)
|
|
|
- {
|
|
|
- kv.Value.Dispose();
|
|
|
- }
|
|
|
-
|
|
|
- this.components.Clear();
|
|
|
- ObjectPool.Instance.Recycle(this.components);
|
|
|
- this.components = null;
|
|
|
-
|
|
|
- // 创建的才需要回到池中,从db中不需要回收
|
|
|
- if (this.componentsDB != null)
|
|
|
- {
|
|
|
- this.componentsDB.Clear();
|
|
|
- if (this.IsNew)
|
|
|
- {
|
|
|
- ObjectPool.Instance.Recycle(this.componentsDB);
|
|
|
- this.componentsDB = null;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 清理Children
|
|
|
if (this.children != null)
|
|
|
{
|
|
|
@@ -497,6 +473,30 @@ namespace ET
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 清理Component
|
|
|
+ if (this.components != null)
|
|
|
+ {
|
|
|
+ foreach (KeyValuePair<Type, Entity> kv in this.components)
|
|
|
+ {
|
|
|
+ kv.Value.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ this.components.Clear();
|
|
|
+ ObjectPool.Instance.Recycle(this.components);
|
|
|
+ this.components = null;
|
|
|
+
|
|
|
+ // 创建的才需要回到池中,从db中不需要回收
|
|
|
+ if (this.componentsDB != null)
|
|
|
+ {
|
|
|
+ this.componentsDB.Clear();
|
|
|
+ if (this.IsNew)
|
|
|
+ {
|
|
|
+ ObjectPool.Instance.Recycle(this.componentsDB);
|
|
|
+ this.componentsDB = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 触发Destroy事件
|
|
|
if (this is IDestroy)
|