Changing particle colour (alpha) at runtime
I have looked through various other questions on this topic, but none of the solutions seem to work for unity 2017.2. Q: How do i change the colour of existing particles (especially the alpha channel) at runtime?
this is how i try it now:
private IEnumerator FadeOutParticles(){
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[myParSystem.particleCount];
myParSystem.GetParticles(particles);
for (float alpha = 255; alpha > 0; alpha -= 255*Time.deltaTime)
{
for(int i = 0; i<particles.Length; i++)
particles[i].color = new Color32(100, 100, 100, (byte) alpha); //deprecated?
yield return null;
}
}
other questions on this site suggested using
"settings.startColor = new ParticleSystem.MinMaxGradient( yourColor );"
but that does not work for existing particles. Or:
particles[i].GetComponent<Renderer>().material.color = myColour[i];
and that wont be good either as it changes the material instead of the color of the particle itself.
Answer by ifurkend · Nov 18, 2017 at 10:40 PM
https://docs.unity3d.com/ScriptReference/ParticleSystem.Particle-startColor.html
The color of individual particle after being emitted is not gradient, just give it a straight Color32 value and you're done.
Your answer
Follow this Question
Related Questions
How do I set the statColor of a particle system through script 2 Answers
Select a random color preset in the particle system through C# 1 Answer
accessing the colliding particle 0 Answers
C# scripting and Particle System incompatibility 1 Answer
is it a necessity to use particles effect in a game? 2 Answers