Recall & Review
beginner
What is the purpose of the Button component in Unity?
The Button component allows users to interact with the UI by clicking or tapping, triggering actions or events in the game.
Click to reveal answer
beginner
How do you assign a function to a Button's click event in Unity?
You select the Button in the Inspector, go to the OnClick() section, click the '+' to add a new event, drag the GameObject with the script into the slot, and select the function to call from the dropdown.
Click to reveal answer
beginner
What is the signature of a method that can be assigned to a Button's OnClick event?
It must be a public method with no parameters and void return type, for example: public void OnButtonClick() {}
Click to reveal answer
intermediate
How can you add a click event listener to a Button via script in Unity?
You get a reference to the Button component and use button.onClick.AddListener(YourFunction); to add the listener.
Click to reveal answer
beginner
Why is it important to use Unity's UI Button component instead of detecting clicks manually on UI elements?
Because the Button component handles user input, visual feedback, and accessibility automatically, making it easier and more reliable to create interactive UI.
Click to reveal answer
Which Unity component do you use to create a clickable button in the UI?
✗ Incorrect
The Button component is designed for clickable UI elements.
How do you add a function to a Button's OnClick event in the Unity Editor?
✗ Incorrect
You assign functions to OnClick events by dragging the GameObject and selecting the method.
What must be true about a method to be assigned to a Button's OnClick event?
✗ Incorrect
OnClick methods must be public and parameterless.
Which code snippet correctly adds a click listener to a Button in script?
✗ Incorrect
Use AddListener with a lambda or method reference to add click events.
Why use Unity's Button component instead of detecting clicks manually?
✗ Incorrect
The Button component simplifies input handling and UI feedback.
Explain how to set up a Button in Unity to call a function when clicked.
Think about the Inspector and the OnClick event section.
You got /3 concepts.
Describe how to add a click event listener to a Button using C# script in Unity.
Remember the syntax for adding listeners in Unity.
You got /3 concepts.