Update colors of existing particles at runtime 5.3.1

How to change the colors of already emitted particles in Unity 5.3.1?
UnityEngine.ParticleSystem.Particle.color is obsolete: color property is deprecated.

The following pseudo-code does not work:

Particles*.startColor = Color(r, g, b, a);* 

ParticleSystem.SetParticles(Particles, Particles.number);

This is how to fix the warning.



How can I fix this warning?

warning CS0618: `UnityEngine.ParticleSystem.startColor' is obsolete: `startColor property is deprecated. Use main.startColor instead.'

When I used startColor error showed up.

I’m using Unity 5.5 and this works for me.

void Start()
		ps = GetComponent<ParticleSystem>();
void Update()
	var main = ps.main;
	main.startColor = new Color(r, g, b, a);

Just make sure you enter r, g, b, a in as floats.

Check out the following documentation as well: