- Home /
How to change the color of Particle System?
I have a particle system for this ball rolling on the ground. I want the particles to change color every time the surface that it is rolling on changes color to correspond with the ground color.
Answer by emc233 · Dec 28, 2013 at 05:06 AM
You can look at the script reference for a Particle System and you can change the color using the Color reference page.
Answer by ScreamingScythe · Mar 27, 2017 at 04:23 PM
After the recent update this is done via:
ParticleSystem.MainModule settings = GetComponent<ParticleSystem>().main;
settings.startColor = new ParticleSystem.MinMaxGradient( yourColor );
You can also assign a Color to ParticleSystem.$$anonymous$$ain$$anonymous$$odule.startColor like:
settings.startColor = yourColor;
as explained in https://docs.unity3d.com/ScriptReference/ParticleSystem.$$anonymous$$ain$$anonymous$$odule-startColor.html
I am confused by the new particle system API. It seems like the color and size properties can no longer be manipulated for individual points/particles. How would I re-write myArray[i].color = new Color(x, 0f, 0f) or myArray[i].startSize = 0.1f or Color c = myArray[i].color; c.g = p.y; myArray[i].color = c for example?
This seems like a cumbersome way to just change a color. Couldn't they have just added some method or a simple way to do it, like how was done before?
Answer by arckex · Jun 05, 2014 at 11:42 PM
emc233 is wrong and not even trying to help. it's through the startColor attribute of the Particle System
this.GetComponent<ParticleSystem>().startColor = new Color(1, 0, 1, .5f);
It actually used to be ParticleSystem.color but that was depreciated sometime ago as it is a procedural calculation so you should use ParticleSystem.startColor to get/set the start color or use ParticleSystem.GetCurrentColor(...) to get the current color
This is useful info if your wondering how you should go about updating depreciated code