Changing the color and transparency of a 3D model at runtime

In my game i want to be able to change the color of a 3d model, for example a white cube, and the transparency, so the cube is slightly see through. I cant store separate 3D models for this as i would need one for every color. I looked around and couldn’t find a way to do this so could somebody please help me with this. Thank you in advance.

Use a material and access it with Getcomponent().material;

with that material you can then do

Material m = Getcomponent().material;
Color newColor = Color.green;// or m.color;
newColor.a = 0.5//set transparency…
Getcomponent().material = m;

your welcome

EDIT: i think that the “<” and “>” got lost when uploaded there should be a Renderer whitin them…