- Home /
Question by
finlay_morrison · Jul 03, 2018 at 05:37 PM ·
meshcolortransparency3d modelschange color
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.
Comment
Best Answer
Answer by KalleRosendahl · Jul 03, 2018 at 07:00 PM
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..