ParticleSystem stop and play ?

Hello,

I have this prefab structure :

The “Effect” prefab and its children all have a Partice System.

I want to start or stop the effects from a script.

I tried everything but it does not work :

ParticleSystem[] childrenParticleSytems = currentInstanceOfObject.GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem particle in childrenParticleSytems)
{
    particle.gameObject.SetActive(false);
// OR
   particle.gameObject.SetActive(true);
}

This way, it is OK to deactivate it but if I reactivate it, it does not work.

ParticleSystem[] childrenParticleSytems = currentInstanceOfObject.GetComponentsInChildren<ParticleSystem>();
                    foreach (ParticleSystem particle in childrenParticleSytems)
                    {
                        particle.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
                        // OR
                        particle.Play(true)
                    }

This way, nothing works (stop or play). The particle effect is always up.

What is the correct way to play/stop all my “Effect” prefab ?

Thanks a lot

Wrote about this just yesterday:

https://discussions.unity.com/t/839651/2

Hi, thanks it works like a charm !

I have a related question if you have a good understanding of ParticleSystem ; do you know how to scale down the whole “Effect” prefab ? It seems the transform.scale does not affect its size.

My “Effect” prefab is the child of a little GameObject but it is too big, I want it to be smaller but I can’t down size it.

Depending on Unity version there are solutions, some more painful than others. It would be necessary to google about it, but it might require redoing the particle, depending on what you’re doing.