Multiple particle systems in one script

Hi!

I currently have four gameobjects with particle systems attatched to them

public ParticleSystem red, blue, green, yellow; and then I have

void Start () {
		green =  GetComponent <ParticleSystem> ();
		red =  GetComponent <ParticleSystem> ();
		yellow =  GetComponent <ParticleSystem> ();
		blue =  GetComponent <ParticleSystem> ();
	}

How do I know that each variable is connected to the correct component? Is there a better way to solve this? I need to be able to activate the emissions separate from each other.
Thank you very much!

When you have multiple components of the same type attached to an object, you can’t use GetComponent to find them; you have to put public fields in your script like this:

public ParticleSystem greenParticles;
public ParticleSystem redParticles;
public ParticleSystem yellowarticles;
public ParticleSystem blueParticles;

This will create fields in your script’s Inspector that you can drag your components to. You can get more details on this subject here and here.