Using color instead of swapping sprites

I decided to go a slightly different direction. Instead of changing the sprite, I change the color of the existing sprite based on if the answer is right or wrong.

        Image buttonImage = answerButtons[index].GetComponent<Image>();

        if(index == correctAnswerIndex) {
            buttonImage.color = correctColor;
            questionText.text = "Correct!";
        } else {
            questionText.text = "Sorry, the correct answer is: \n" + question.GetAnswer(correctAnswerIndex);
            buttonImage.color = wrongColor;
        }
1 Like

Privacy & Terms