Here’s an alternative solution for those who’d like it. There’s some unneccessary repeat in the code. The only thing that changes between a correct and incorrect answer is what we set the question.text to. So everything else can be moved outside the if/else block.
public void OnAnswerSelected(int btnIndex)
{
int correctAnswerIndex = question.GetCorrectAnswerIndex();
Image buttonImage = answerButtons[correctAnswerIndex].GetComponent<Image>();
buttonImage.sprite = correctAnswerSprite;
if (btnIndex == correctAnswerIndex)
{
questionText.text = "Correct!";
}
else
{
questionText.text = $"I'm sorry, the correct answer was; \n{question.GetAnswer(correctAnswerIndex)}.";
}
}