title: Unity: Quiz game multiple choice button colors
body: <p>I'm doing a multiple choice quiz game, and im tryinng to highlight the correct answer in green if the wrong answer is clicked. for example if i have A , B , C and D and "A" is the correct answer. i want if i choose "B" to turn B to red color and display the correct answer to green which is in this case "A". Right now i have if i click the right answer it displays green, as i want it. and if i press wrong answer it displays red. what im missing is when i click wrong answer i want to also highlight the correct answer. </p>
  
  <p>Here's my functions:</p>
  
  <p>In the Game controller:</p>
  
  <pre><code>public bool theAnswerIsCorrect;
  
  public bool IsCorrected()
  {
      return theAnswerIsCorrect;
  }
  
  public void AnswerButtonClick(bool isCorrect)
  {
      if (isCorrect)
      {
          Debug.Log("I'm Correct");
          theAnswerIsCorrect = true;
          playerScore += currentRoundData.pointAddedForCorrectAnswer;
          scoreDisplayText.text = "Score: " + playerScore.ToString();
  
  
      }
  
      else
          theAnswerIsCorrect = false;
  
  
  
      // Do we still have questions?
      if (questionPool.Length &gt; questionIndex + 1)
      {
          //questionIndex++;
  
          UpdateQuestionIndex();
          StartCoroutine(DelayTime(3));
        //  ShowQuestion();
      }
  
      else
      {
          EndRound();
      }
  }
  </code></pre>
  
  <p>And this is an a class that just holdes my data </p>
  
  <pre><code>public class answerData {
  
  public string answerTxt;
  public bool isCorrect;
  
  
  }
  </code></pre>
  
  <p>This is being used in the ButtonClick function (the code in the begging of the question) -> this line </p>
  
  <pre><code>        gameController.AnswerButtonClick (AnswerData.isCorrect);
  </code></pre>
  
  <p>And in the inspector i specify by the bool what is the correct answer</p>
  
  <p>*** NEW SCRIPT HERE "Picking up the Correct button"</p>
  
  <pre><code>// store reference to btn text
  public Text answerText;
  
  private answerData AnswerData;
  private GameController gameController;
  
  public static AnswerButton _instace;
  
  private void Awake()
  {
      _instace = this;
  }
  
  // Use this for initialization
  void Start () 
  {
      gameController = FindObjectOfType&lt;GameController&gt; ();
  
  
  }
  
  public void Setup(answerData data)
  {
      AnswerData = data;
      answerText.text = AnswerData.answerTxt;
  }
  
  IEnumerator ReturnButtonColor()
  {
      yield return new WaitForSeconds(2.9f);
      GetComponent&lt;Button&gt;().image.color = Color.white;
      Debug.Log("HiB");
  
  
  }
  
  
  public void HandleClick()
  {
      gameController.AnswerButtonClick (AnswerData.isCorrect);
  
      if (gameController.IsCorrected())
      {
         GetComponent&lt;Button&gt;().image.color = Color.green;
          Debug.Log("im true");
          StartCoroutine(ReturnButtonColor());
  
  
      }
  
      else
      {
          GetComponent&lt;Button&gt;().image.color = Color.red;
        //  gameController.IsCorrected().image.color = Color.green;
          StartCoroutine(ReturnButtonColor());
  
      }
  
  
  }
  </code></pre>
  
  <p>Thank you</p>