- Home /
UI Buttons dont react on click
Hello everyone,
I have multiple canvas's in my scene, but everything worked fine before. Now if I click on any buttons, nothing happens. I've already checked the Eventsystem-Log and it says that I clicked the button ive clicked, but my Debug.Log entry doesn't show up in the console. If I disable my Player-Object everything works fine. I can't find out what I did wrong.
Maybe you should know that is use "Input.ResetInputAxes()" everytime the play shouldn't do any inputs. When I enable the Menu where the button is, Timescale is set to 0f but this worked before, too.
Raycast is acitve, nothing seems to block my buttons, the react if I hover over them. Maybe some has an idea what's causing the issue.
Thank you in advance if you try to help!
Note: I've checked several other questions but any answer there unfortunately couldn't help me.
EDIT: I just saw that "eligibleForClick" will set to True and stays true. On a different canvas it just stays false. Maybe you can use this information.
EDIT 2: After a few tests I've figured out that the buttons work if I disable my boundary object - a simple cube which deletes every game object OnTriggerExit (Destroy(other.gameObject)). This object is connected to my player. However I had this game object before where everything worked. If I disable it my buttons work but OnMouseDown etc won't.
I don't know if this is important, but I also deactivated VSync and set TargetFrameRate to 30.
Did you add the callback through inspector or through code?
I've deactivated VSync in QualitySettings inspector and call [ if (Application.targetFrameRate >= 30) Application.targetFrameRate = 30;] in LateUpdate()
Answer by Thaldin · Jan 22, 2018 at 04:15 PM
So I still don't know why this error occurred even if I didn't change much, I figured out that a Trigger Collider was blocking my inputs. As a solution I simply deactivate this trigger box if I open any menus. Thank you all trying to help me.
Answer by Neamtzu · Jan 19, 2018 at 02:56 PM
Check if you have another canvas in front of the one with the buttons that has a GraphicRaycaster component attached. If blocking mask is set to Everything it will block everything that is rendered under that canvas.
This didn't fix the problem, but I've completely ignore that. Thank you.
Answer by UnitedCoders · Jan 19, 2018 at 03:47 PM
Make sure your canvas has EventSystem.
The EventSystem unfortunately conflicts with the new Input System.
Answer by sh_code · May 04, 2018 at 07:55 AM
old question, but for the record/completeness: hierarchy order of UI elements matters! objects lower in the hierarchy get drawn later (on top of everything above them in hierarchy), and also get the events sooner! (rendering happens back-to-front, event propagation happens front-to-back) meaning if you have a button,, and below it in hierarchy you have a panel that covers the button, even if the panel is invisible (not disabled as an object, just no image and zero alpha on background color), it will still recieve, and therefore block propagation of pointer events .
if you want to prevent this, either remove GraphicRaycaster from the element (if it is a Canvas and therefore has one), or change its blocking mask to ignore a certain layer and put the element that does the blocking on that layer to stop it from doing the blocking, OR put a CanvasGroup component on the object/UI element that does the blocking and uncheck both "Interactable" and "BlocksRaycasts"