GetColor/SetColor not working to change alpha of ParticleRenderer

I’m trying to change the alpha of a particle system’s material through script, and it’s not working. Note that I tried it also on a regular object with a regular mesh renderer using the same particle shader (I’m using the built-in “Particles/Additive” shader).

Here’s what I’m trying:

var color : Color = chargeParticles.renderer.material.GetColor("_TintColor");
color.a = 20;
chargeParticles.renderer.material.SetColor("_TintColor", color);
chargeParticles.emit = true;

But it’s not working, but it’s not logging any errors, either.

2 Answers

2

Color and alphas in code go from 0 to 1. In other words, solid light grey is (0.75, 0.75, 0.75, 1) and pink is (1, 0.5, 0.5, 1) Setting alpha to 20 should make it “super opaque” (which looks like normal opaque.)

Could also be something else wrong (for example, misspelling TintColor doesn’t give me errors - just does nothing.)

Blamo! That was it.

The colors of particles are dependent on the vertex colors of each particle; SetColor won’t do anything.

zomg Eric was wrong about something?! I feel like my world is coming undone.

I was still upvoted though. ;)

That's because your my favorite!