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;

var currentColour : int = 0;
var maxColours : int = 4;

function Update()
{
    if ( Input.GetMouseButtonDown(0) )
    {
        currentColour ++;

        if ( currentColour >= maxColours  )
        {
            currentColour = 0;
        }
        
        switch( currentColour )
        {
            case 0 : 
                // change colour to the first colour
            break; 

            case 1 : 
                // change colour to the second colour
            break; 

            case 2 : 
                // change colour to the third colour
            break; 

            case 3 : 
                // change colour to the fourth colour
            break; 
        }
    }
}

Does this mean I just did your homework?