Managing ParticleSystems

Hey,
i find tons of tutorials out there about how to create particleSystems in the unity editor, but not really anything about managing or actually using those in my projects/scripts.

  • how do i store particleSytems? Do i store gameObject prefabs that have ParticleSystems attached to them?
  • how do i link particleSystems to script variables that want to use them? If i define [SerializeField] ParticleSystem varName; and then click on the circle in the editor to link a particleSystem to it, i don’t even get the particleSystem i created and stored as a gameObject prefab earlier displayed.
  • how do i instantiate particleSystems? Do i instantiate gameObject prefabs that have a particleSystem attached? Do i attach particle system to existing objects when i want to play them?
  • how do i cleanup once the particle system finished?

The answer to pretty much all of these questions is that ParticleSystems - like all components - are attached to GameObjects. So you store it as a prefab with a ParticleSystem attached, you instantiate the prefab to instantiate the particle system, and you clean it up by destroying the GameObject.

The one question I didn’t follow was this:

Did you make sure that you are linking to the prefab and not an object in the scene?