From edae7c596c93f2cd058fe5684591ba9565a99151 Mon Sep 17 00:00:00 2001 From: zxg0622 <247274249@qq.com> Date: Wed, 9 Oct 2019 17:29:38 +0800 Subject: [PATCH] fix particle destroy attatched to uimodel (#5504) --- cocos/core/3d/framework/model-component.ts | 2 +- cocos/particle/particle-system-component.ts | 2 +- cocos/particle/renderer/particle-system-renderer.ts | 6 ++++-- cocos/particle/renderer/trail.ts | 2 +- cocos/ui/components/ui-model-component.ts | 4 +++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cocos/core/3d/framework/model-component.ts b/cocos/core/3d/framework/model-component.ts index 022bb9ba2e..5634b590a4 100644 --- a/cocos/core/3d/framework/model-component.ts +++ b/cocos/core/3d/framework/model-component.ts @@ -194,7 +194,7 @@ export class ModelComponent extends RenderableComponent { public onDestroy () { if (this._model) { - this._getRenderScene().destroyModel(this._model); + this._model.scene.destroyModel(this._model); this._model = null; } } diff --git a/cocos/particle/particle-system-component.ts b/cocos/particle/particle-system-component.ts index 615ff180d5..854756787c 100644 --- a/cocos/particle/particle-system-component.ts +++ b/cocos/particle/particle-system-component.ts @@ -466,7 +466,7 @@ export class ParticleSystemComponent extends RenderableComponent { if (this.isValid) { const r = this.renderer as any; if (r && r._model) { - r._model.destroy(); + r._model.scene.destroyModel(r._model); r._model = null; r.onEnable(); r._updateModel(); diff --git a/cocos/particle/renderer/particle-system-renderer.ts b/cocos/particle/renderer/particle-system-renderer.ts index 2c19ad8f5d..7b32ef14d0 100644 --- a/cocos/particle/renderer/particle-system-renderer.ts +++ b/cocos/particle/renderer/particle-system-renderer.ts @@ -258,8 +258,10 @@ export default class ParticleSystemRenderer { } public onDestroy () { - this._particleSystem._getRenderScene().destroyModel(this._model!); - this._model = null; + if (this._model) { + this._model.scene.destroyModel(this._model); + this._model = null; + } } public clear () { diff --git a/cocos/particle/renderer/trail.ts b/cocos/particle/renderer/trail.ts index d9f1bf1724..628fa99663 100644 --- a/cocos/particle/renderer/trail.ts +++ b/cocos/particle/renderer/trail.ts @@ -357,7 +357,7 @@ export default class TrailModule { public destroy () { if (this._trailModel) { - this._particleSystem._getRenderScene().destroyModel(this._trailModel!); + this._trailModel.scene.destroyModel(this._trailModel); this._trailModel = null; } if (this._trailSegments) { diff --git a/cocos/ui/components/ui-model-component.ts b/cocos/ui/components/ui-model-component.ts index 19d1b526c1..a031887649 100644 --- a/cocos/ui/components/ui-model-component.ts +++ b/cocos/ui/components/ui-model-component.ts @@ -70,7 +70,9 @@ export class UIModelComponent extends UIComponent { } this._modelComponent._sceneGetter = null; - this._modelComponent.recreateModel(); + if (cc.isValid(this.node, true)) { + this._modelComponent.recreateModel(); + } } public updateAssembler (render: UI) {