Change material color at runtime!!

I wonna change the color of the material at the runtime (particle system)!

var partColor : GameObject; 
function Update(){ 
if (Input.GetButton ("Jump")) {
partColor.renderer.material.color = Color.red; 
} 
}

Why doesnt it work? What am i doing wrong?

Celofa

The color of a particle can be modyfied by Particle.color.

Hello, well try this piece of code:

function Start () {

// Set glossy shader so that specular color is used renderer.material.shader = Shader.Find (" Glossy");

// Set red specular highlights

renderer.material.SetColor ("_SpecColor", Color.red); }

MaterialPropertyBlock might be what you're looking for: http://unity3d.com/support/documentation/ScriptReference/MaterialPropertyBlock.html

With it, meshes using the same material can be different colors.

YourParticleTransform.GetComponent().material.SetColor(“_TintColor”, DesiredColour);
Works if you are using Particle Materials

You could also try this: Search results for 'change color on particles' - Unity Discussions