Laya粒子与Unity的一点不同

Posted on Tue 26 October 2021 in 游戏开发

1. 当多个粒子呈现父子关系,父节点的play并不会影响子节点,这和unity不同。

laya

LayaAir/ShurikenParticleSystem.ts at master · layabox/LayaAir (github.com)

unity:

Unity - Scripting API: ParticleSystem.Play (unity3d.com)

2. 而laya粒子节点从场景树上remove之后再addChild又会重新播放,是因为:

LayaAir/ShuriKenParticle3D.ts at 23ec5dc957ac9de14d2bde9eca6673dde7e0d4cc · layabox/LayaAir (github.com)

/**

* @inheritDoc

* @override

* @internal

*/

_activeHierarchy(activeChangeComponents: any[]): void {

​ super._activeHierarchy(activeChangeComponents);

​ (this.particleSystem.playOnAwake) && (this.particleSystem.play());

}

/**

* @inheritDoc

* @override

* @internal

*/

_inActiveHierarchy(activeChangeComponents: any[]): void {

​ super._inActiveHierarchy(activeChangeComponents);

​ (this.particleSystem.isAlive) && (this.particleSystem.simulate(0, true));

}

这一段代码。

3. 如果想给粒子特效添加一个父节点,方便unity内调试,可以勾掉Shape,并将Emission选为0就可以了。

img