Problem
The Unity Particle Pack provides particle effects in form of prefabs, where multiple particle systems are used to combine the whole effect. That leads to the problem that if I want to change a property of the visual effect, I can’t just change a property of one particle system.
Prefab (BigExplosion
)
The whole prefab:
ParticleSystem
s in the prefab:
Example Code
GameObject particle = (GameObject) PrefabUtility.InstantiatePrefab(ParticlePrefab, transform);
particle.transform.position = position;
particle.transform.rotation = Quaternion.identity;
ParticleSystem particleSystem = particle.GetComponent<ParticleSystem>();
ParticleSystem.MainModule main = particleSystem.main;
main.simulationSpace = ParticleSystemSimulationSpace.World;
ParticleSystem.CollisionModule collision = particleSystem.collision;
collision.enabled = true;
collision.type = ParticleSystemCollisionType.World;
collision.sendCollisionMessages = true;