- Home /
How to change the colour of my car?
Hello. I am developing a racing game with unity3D. I have also a shop system where you can buy Upgrades, equipment, boosters etc. and now I want to make a show for Car Designs, in which you can buy new designs for the car. How can I convert this? How can I change the colour of a prefab? Please, I need help:)
Answer by fafase · Apr 05, 2012 at 11:31 PM
var texture1 : Texture;
var texture2 : Texture;
function Start(){
renderer.material.mainTexture = texture1;
}
function Update(){
if(buy new painting)
renderer.material.mainTexture = texture2;}
Have a look there http://unity3d.com/support/documentation/ScriptReference/Material.html so that maybe you will find exactly what you want.
hey @worldofcars and @fafase sir could you please tell me how to apply the same functionality on the click of a gui button.
i have written the same script with the keypress function but when i tried it on the car with gui button it does not change the color.
however when i apply the same script to a single surface , the color changes.
i am really stuck on this for the past three days.
Your answer
Follow this Question
Related Questions
When complete level change colour of ball. 1 Answer
script help gameobject to playercar 1 Answer
referring to a particular material 0 Answers
script not working on multiple objects 0 Answers
Flickering materials/textures when changed by script 1 Answer