Cannot Select On Click Function

At 5:23, when the four AnswerButtons are selected and then No Function is changed in the Inspector via the On Click () dropdown box, nothing is happening when I select the dropdown box, it just continues to say “No Function”, there are no options that appear. I did previously drag QuizCanvas into the None Object box underneath On Click, Runtime Only. I don’t see that I did anything different or missed any steps in the video. Please advise, thank you.

1 Like

Hi!

If the options are grayed out it means you haven’t populated the Object Parameter.

To populate it just drag and drop an object into the Object Parameter or click on it and select the desired object, once you do that the options will become available.

Keep in mind that the images above are just a quick reference, the object I selected might be different from the one Gary selected during the course.

Hope this helps!

Edit: Remember that changes done during runtime will be undone once you stop playing, that’s probably why you’ll have to reselect the object.

Hi, thank you for the response, but as I said in the original post, “I did previously drag QuizCanvas into the None Object box underneath On Click, Runtime Only.” AKA populate the Object Parameter. Any other ideas of what is going wrong?

Thank you.

Hi Elijah,

Please click on your button game object in the Hierarchy, then share a screenshot where we can see how you configured the OnClick field. If you cannot find your own method in the dropdown menu, check your code and make sure the method is public. Remember you can also look at the lecture code changes via the link in the Resources of each lecture.

I figured it out with your help! The problem was that one of the curly brackets was in the wrong place, but it was your tip about checking as to whether the method was public that led me there. The word public was there but there was a red squiggly line underneath it, I guess indicating that something was wrong, and so I just checked everything and that’s when I found it. Thank you so much for your help!

1 Like

Good job on fixing the problem! :slight_smile:

If your method was declared inside another method and if that “inner” method had the public access modifier, the compiler complains bcause access modifiers work at instance level only, not within methods.

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

Privacy & Terms