Material.SetColor only works in Start function?

Hey guys,

I am making a virtual mixing console. Currently I am trying to change the color of a certain channel fader when the user presses the appropriate key (1 for channel 1, etc).

I start by declaring my Materials (one for each fader):

public Material fader1Material;
public Material fader2Material;
public Material masterMaterial;

Then initializing them as white:

//Initalize Fader Colours

masterMaterial.SetColor("_Color", Color.white);
fader1Material.SetColor("_Color", Color.white);
fader2Material.SetColor("_Color", Color.white);

However, if I alter the Material’s color anywhere outside of the start function, it does not change color (This is in update):

if (Input.GetKey(KeyCode.Alpha1))



It does not throw an error, just doesn’t work as intended. Pressing ‘1’ successfully calls ChangeChannel(), but the color fails to change.

Any help would be appreciated!

This is really strange… I tried to replicate your problem, but got no problem…
Are you sure your material is assigned to your script (check in the Inspector, you should have something like this : 117462-capture.png

This is the only thing I can tell, hope it helps.