filmov
tv
Unity Button Not Clickable? Fixes for UI Interaction Bugs in Unity

Показать описание
Sometimes buttons don't work in Unity, in this video we see a simple way to test if buttons are working properly in Unity and then we see three reasons why a button does't work in Unity.
First of all, to test if a button is working we are going to create a new button, in the inspector add an On Click event, then drag some object (like the directional light) to test if the button is working and in the drop down menu of the On Click event choose a function like SetActive (inside GameObject), this way, when we press the button, we can deactivate the directional light and quickly test if a button works in Unity.
In the second part of the video we analyze possible reasons why a button doesn't work in Unity.
The first reason why a button might not work in Unity is that we accidentaly delete the EventSystem from the scene and therefore there is no way to detect mouse events on the user interface.
The second reason why buttons might not work in Unity is either the Button component is disabled in the inspector or its "interactable" field is unchecked, we may accidentaly uncheck these boxes and if we do, buttons won't work.
The third reason why buttons might not work in Unity is that there are no Raycast Target object in the button and therefore Unity has no way to know if we click on that button, a default Button in Unity is compose by a parent object with an Image component and a child object with a Text or TextMeshPro component, both the Image and the text act as Raycast Target by default, but if you accidentally uncheck the Raycast Target option in the component the button will not work.
____________________________________________________________
____________________________________________________________
TIMESTAMP
0:00 Intro
0:15 How to TEST IF BUTTON WORKS in Unity
1:34 FIRST REASON - No EventSystem
2:14 SECOND REASON - Button disabled or non-interactable
3:09 THIRD REASON - No RaycastTarget
First of all, to test if a button is working we are going to create a new button, in the inspector add an On Click event, then drag some object (like the directional light) to test if the button is working and in the drop down menu of the On Click event choose a function like SetActive (inside GameObject), this way, when we press the button, we can deactivate the directional light and quickly test if a button works in Unity.
In the second part of the video we analyze possible reasons why a button doesn't work in Unity.
The first reason why a button might not work in Unity is that we accidentaly delete the EventSystem from the scene and therefore there is no way to detect mouse events on the user interface.
The second reason why buttons might not work in Unity is either the Button component is disabled in the inspector or its "interactable" field is unchecked, we may accidentaly uncheck these boxes and if we do, buttons won't work.
The third reason why buttons might not work in Unity is that there are no Raycast Target object in the button and therefore Unity has no way to know if we click on that button, a default Button in Unity is compose by a parent object with an Image component and a child object with a Text or TextMeshPro component, both the Image and the text act as Raycast Target by default, but if you accidentally uncheck the Raycast Target option in the component the button will not work.
____________________________________________________________
____________________________________________________________
TIMESTAMP
0:00 Intro
0:15 How to TEST IF BUTTON WORKS in Unity
1:34 FIRST REASON - No EventSystem
2:14 SECOND REASON - Button disabled or non-interactable
3:09 THIRD REASON - No RaycastTarget
Комментарии