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

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

Thank you so much for making this video!!!! I'm absolute beginner in Unity, and I was struggling with buttons for almost an hour until I found your video! So helpful.

miayang
Автор

Bro you are a legend! Subscribed! Note to anyone with this problem: If you ever disabled old Input and select only use new Input in Edit>Project Settings, then it will disable your buttons in all of the scenes in most cases. In that case, Select>EventSystem GameObject in all of the scenes in the hierarchy and in Inspector select>"Replace with...". Solved it for me.

mb
Автор

Thank you so much, you saved me after an hour of research

MaximeCanonne
Автор

Thank you so much I completely forgot I deleted the EventSystem and was stressing over why the buttons weren't working😭😭

iamgroot
Автор

Thanks for the help! I had accidentally deleted the EventSystem and didn't even notice.

vikaviruz
Автор

IT the eventsystem!!!. Dam thank you Soooo much

greeng
Автор

Guys, what was happening to me was that it wasn't detecting the buttons because I had an active panel over another one, but without it being visible. I think when it doesn't know which panel is first, this happens like in layers, so if it helps you, check all the panels you have in the scene if it's not causing interference.

vdka
Автор

Tysm! I indeed accidently deleted event system and I tried to fix it like 5 hrs yesterday.

piorun
Автор

thx man, saved my day, i use canvas as a prefab and in other scenes EventSystem was missing

RonikCz
Автор

thank you so much the No raycast Target was for me, thank you man

gabrielemartina
Автор

You the goat fr thank u for the help you the goat frfr

stardust
Автор

sup man, do you know why using the event system with the Input System UI Input Module, the UI buttons dont receive the inputs made by controller and keyboard, but when using the mouse the button works, like, with controller and keyboard i even cant navigate with the arrows or dpad :(

Kroklark
Автор

One more thing, make sure if the button is in a panel, that there is nothing in front of it (images or other elements)

MO-zbfh
Автор

Also there might be a chance that you have an image or something else not turned off but it doesn't have an alpha so you can't see it and it's being below the button in the hierarchy! I had a text fading animation that was below my button and it wasn't turned off so i completely forgot about it xD

andreychumakov
Автор

Thank you so !! I have been having this problem and trying to solve it for hours :'' with the thought of something is wrong with my code. YOU SAVE MY DAY!

Stupid me crying with happy tears T..T

yucoeverywhere
Автор

Thanks a lot for your help ! I simply forgot to add an eventsystem ahah ^^'

Richartichaut
Автор

There was a very similar problem. The button or parent object must have a "Graphic Raycaster" component.

phubuser
Автор

I am learning unity. The problem for me was that I used textmesh tex before buttons. so the event system was deactivated by default. I had to activate the eventsystem for the buttons to be clickable

pembaonlinemedia
Автор

Bro I have EvenSystem, Graphics Raycaster on, and all nessesary check on that you mentioned ... but but but my button steel not working .. i am trying to move simple cube left or right by clicking the button . but when game start the cube run autometiclly, and button did nod work .. help if you can

TajAhmed-wtoe
Автор

actual genius. event system was the answer in my case.

pommezzz
visit shbcf.ru