- Home /
Unity UI button does not detect click
So I'm trying out Unity's UI buttons, and I can't seem to get them to work when I click. I looked at the UI button video that the Unity guys made, but that didn't help me solve my problem. Whenever I click on the button I have, nothing happens. No color change or anything. I tried deleting-readding the button. But that didn't help. Still couldn't get the clicking to work.
I checked on some places online, and all they said was to check to make sure I have an EventSystem, a graphic raycaster, and make sure that the button is a child of a canvas. I got all three of these. So what else should I check/try to get my button working?
By the way, this is all in Unity 5's 2D mode, if that matters.
So I also tried changing around the position/anchors of the button... didn't work. I even tried deleting everything except for the camera, canvas, button, and event system... didn't work either.
@Colbanus
Right now, for the OnClick() function, I just put in a function that prints out a message in the console. But even if I didn't have the OnClick() function, the button should at least change color when I click it, right?
@$$anonymous$$eySama yea i see, what do you have on the EventSystem?
I am not sure. I have always used Canvas -> Render $$anonymous$$ode -> Screen Space Overlay. I checked out screen space camera and it looks like it is the same idea... $$anonymous$$y only guess is that it is not registering clicks because you have a transparent object of some sort on top of your button. Possibly your item display area? Check all of your layering.
$$anonymous$$aybe just try closing and reopening Unity (I'm sure you already have).
Answer by KeySama · Sep 05, 2015 at 07:43 AM
Figured it out. Turns out, I needed to add in an input in my InputManager for mouse clicks. Whoops.
Answer by erfan · Sep 05, 2015 at 07:54 AM
make sure that there is not anything in front of your button. perhaps some other UI element have extra boundaries that blocks raycast to reach to your button.
Your answer
![](https://koobas.hobune.stream/wayback/20220612002610im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to detect button presses and change child object text in the button's Parent Object script 0 Answers
Help check click out of UI 2 Answers
How to make UI buttons so my player can move along certain lines 0 Answers
How to make a button animation in menu 1 Answer
Enable UI Button from Prefab 1 Answer