From b93e0e4701c7011176eeec5c109dda7f4ea632e0 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 23 Feb 2021 13:30:46 +0900 Subject: [PATCH] fix: ParticleSystem creates particles in wrong position during pre-warm Close #147 --- Scripts/UIParticle.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index 11e4be9..26540f4 100755 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -178,6 +178,11 @@ namespace Coffee.UIExtensions particles.Exec(p => p.Stop()); } + public void Clear() + { + particles.Exec(p => p.Clear()); + } + public void SetParticleSystemInstance(GameObject instance) { SetParticleSystemInstance(instance, true); @@ -411,17 +416,20 @@ namespace Coffee.UIExtensions private new IEnumerator Start() { + // #147: ParticleSystem creates Particles in wrong position during prewarm // #148: Particle Sub Emitter not showing when start game - var hasPlayingSubEmitter = particles.AnyFast(ps => + var delayToPlay = particles.AnyFast(ps => { ps.GetComponentsInChildren(false, s_ParticleSystems); - return s_ParticleSystems.AnyFast(p => p.isPlaying && p.subEmitters.enabled); + return s_ParticleSystems.AnyFast(p => p.isPlaying && (p.subEmitters.enabled || p.main.prewarm)); }); s_ParticleSystems.Clear(); - if (!hasPlayingSubEmitter) yield break; + if (!delayToPlay) yield break; Stop(); + Clear(); yield return null; + Play(); }