Skip to content

Particle Destroyer

Description

The Particle Destroyer waits until all the particles in the simulation are finished and then destroys the GameObject.

Example

You can add the component to the particle root transform or in runtime, as shown in the example below.

1
2
3
4
5
6
7
// Adds the component to the instantiated particle, 
// so it’s get destroyed when the execution finishes.
private void InstantiateParticle()
{
    GameObject particle = Instantiate(prefab, position, rotation) as GameObject;
    particle.AddComponent<ParticleDestroyer>();
}