- Home /
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[i].startColor = Color(r, g, b, a);
ParticleSystem.SetParticles(Particles, Particles.number);
Thanks! FF
Answer by StartStart · Oct 13, 2016 at 07:01 AM
Edit
This is how to fix the warning.* https://docs.unity3d.com/550/Documentation/ScriptReference/ParticleSystem-main.html
//////////////////////////////
Same!
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.
Answer by Jack_In_The_Sack · Jan 20, 2017 at 07:09 AM
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: https://docs.unity3d.com/550/Documentation/ScriptReference/ParticleSystem.MainModule-startColor.html
Your answer