From 0aea3d2bdbaa38f85402d4df3eefd8fb4d4aa275 Mon Sep 17 00:00:00 2001 From: cary <39078800+caryliu1999@users.noreply.github.com> Date: Fri, 5 Mar 2021 19:01:56 +0800 Subject: [PATCH] Fix the error when deactive node in onLoad. (#8326) --- cocos/core/scene-graph/component-scheduler.ts | 2 +- cocos/particle-2d/particle-system-2d.ts | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cocos/core/scene-graph/component-scheduler.ts b/cocos/core/scene-graph/component-scheduler.ts index 7123f4ee73..18bebddc09 100644 --- a/cocos/core/scene-graph/component-scheduler.ts +++ b/cocos/core/scene-graph/component-scheduler.ts @@ -80,7 +80,7 @@ function stableRemoveInactive (iterator, flagToClear) { let next = iterator.i + 1; while (next < array.length) { const comp = array[next]; - if (comp._enabled && comp.node._activeInHierarchy) { + if (comp.node._activeInHierarchy) { ++next; } else { iterator.removeAt(next); diff --git a/cocos/particle-2d/particle-system-2d.ts b/cocos/particle-2d/particle-system-2d.ts index 87a261b787..8c9d2815a8 100644 --- a/cocos/particle-2d/particle-system-2d.ts +++ b/cocos/particle-2d/particle-system-2d.ts @@ -673,15 +673,6 @@ export class ParticleSystem2D extends Renderable2D { public declare _renderSpriteFrame: SpriteFrame | null; public declare _simulator: Simulator; - /** - * @en Play particle in edit mode. - * @zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 - */ - @serializable - @editable - @tooltip('i18n:particle_system.preview') - private preview = true; - /** * @en If set to true, the particle system will automatically start playing on onLoad. * @zh 如果设置为 true 运行时会自动发射粒子。 @@ -689,7 +680,7 @@ export class ParticleSystem2D extends Renderable2D { @serializable @editable @tooltip('i18n:particle_system.playOnLoad') - private playOnLoad = true; + public playOnLoad = true; /** * @en Indicate whether the owner node will be auto-removed when it has no particles left. @@ -698,8 +689,16 @@ export class ParticleSystem2D extends Renderable2D { @serializable @editable @tooltip('i18n:particle_system.autoRemoveOnFinish') - private autoRemoveOnFinish = false; + public autoRemoveOnFinish = false; + /** + * @en Play particle in edit mode. + * @zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 + */ + @serializable + @editable + @tooltip('i18n:particle_system.preview') + private preview = true; @serializable private _custom = false; @serializable