- Home /
Change particle tint color via script
Hey all!
First, sorry for my bad english.
I´m using Legacy Shaders/Particles/Additive on a texture for a ParticleSystem in my game. This have a StartColor selected and this is working well.
Now, I wanna change this color at runtime.
So, in my Start method I set the particle material:
this.sphereMaterial = sphereParticle.GetComponent<ParticleSystemRenderer>().material;
And when I wanna change color and show the particle I do:
this.sphereMaterial.SetColor("_TintColor", new Color(1.0f, 0.0f, 0.0f, 1.0f));
this.sphereParticle.Play();
But now particle effect is not shown. Im forgetting something?
Answer by Luis_Gan · Apr 28, 2020 at 08:54 PM
Use Color32 instead of Color.
I changed it to
this.sphereSpark$$anonymous$$aterial.SetColor("_TintColor", new Color32(255,0,0,255));
this.sphereParticle.Play();
But is not working. I cant see the effect when I set a color at runtime
Are you sure the problem is caused by color? Try Color.red
$$anonymous$$y problem was another, I must continue learning about shaders and materials. I was able to solve it creating a material on the fly and assigning it to a specific shader and then changing the material color using shaders properties.
Thank you for your help, I had no idea about Color32 and was nice read about it
Your answer
Follow this Question
Related Questions
how to solve shader/texture problem: putting white icons on colored planes 1 Answer
Assign Texture To Material Unity 4.6 1 Answer
Combine Shaders 0 Answers
Finding a list of properties in Shaders 1 Answer
Transparent shader and scrolling 0 Answers