OnAnswerSelected function is not available

Hi there,

Instructor easily adds OnAnswerSelected as a function to the button but it seems I don’t have that option on the dropdown :sweat_smile:

This is at 5:23 of the 59th video on 2d Unity course.

I am not sure what the issue here and could not find anything related to this in the forums. Could you please help me about it?

Thanks

Hi,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? Is the OnAnswerSelected public in your code? Did you attach your script to the same Inspector as the Button component?


See also:

There’s an error in the script. If you just added the function, it will not show up because Unity is unable to compile the code. Fix the error and try again

okay after changing this line " Image buttonImage = answerButtons[index].GetComponent(); "
to this " answerButtons[index].GetComponent().sprite = correctAnswerSprite; "

I managed to compile and see the “OnAnswerSelected” at the dropdown.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms