Hey I’m new to unity and currently in school for programming. Right now were doing a project where we make a cube and with the press of certain keys make it change to select colors. I have the code for setting the color and for targeting the gameobject. but what i can’t figure out is how to make it change color when i press the button for a different color. help would be appreciated… or even just some advice. i searched online but all my searches just dance around the subject
Edit : my code so far
var target : GameObject;
var pick;
function Start () {
switch (pick){
case 'a': target.renderer.material.color = Color.blue;
break;
case 's': target.renderer.material.color = Color.cyan;
break;
case 'd': target.renderer.material.color = Color.green;
break;
case 'f': target.renderer.material.color = Color.yellow;
break;
case 'q': target.renderer.material.color = Color.red;
break;
case 'w': target.renderer.material.color = Color.magenta;
break;
case 'e': target.renderer.material.color = Color.grey;
break;
case 'r': target.renderer.material.color = Color.white;
break;
}
}
function Update () {
var pick = Input;
}return pick;
If you submit your code when asking a question, we can see what you are trying to do and help from there. * http://forum.unity3d.com/ * http://answers.unity3d.com/page/newuser.html * http://video.unity3d.com/video/7720450/tutorials-using-unity-answers
– AlucardJay