UI buttons not working properly :(

Hi All,

I would really appreciate if anyone can answer this or at least point me in right direction.

The issue that I am facing is - The UI buttons not registering mouse when on “button image”, but it does register the mouse when it is in empty space inside the same button. Let me explain - please see the image below, In t

You can see the button’s area is a square as marked by the blue dots. Inside this area, there are places where when mouse is there, the mouse is registered (see image - this area is the difference of bigger square minus the image circle). But when the mouse is on the main area of image - i.e. the image of button ( = inner yellow circle ), mouse click or hovering or nothing is detected :frowning:
This is happening with all the buttons I have. Also, this is happening in both Unity editor and Android phone.
Hope it is clear what issue I am facing. Also attaching hierarchy of canvas and everything else you guys may require. Please help :expressionless:

When the game is running, click the Event System then Hover over and click the parts of the image to see what the feedback is. I actually had and solved this exact issue a while back but it may take a while for the info to come back to me.

–

Well I think the suggestion to set scale of EventSystems to 1 helped me a lot. Responses of lot of buttons improved a lot. Many, still are glitchy but well atleast some improvements. edit: Setting the camera to Overlay mode helped a lot and looks like its working now flawlessly, however Ill continue to keep an eye out if the issue seems to return. Thanks meat5000 for the answer :)

–

6 Answers

6

I presume the image is on top of the button? If so it probably has a greater z axis value to it, so click on your image and change the z axis value to 1 less the of which your button’s z axis. Hope this helps!

The image and button are the components of same GameObject. :)

–

This was my issue. An image with a transparent background was covering part of my button. I was able to solve the issue by unchecking "Raycast Target" on the offending image. I also read in a comment above that moving your buttons to the bottom of your canvas element will also probably sort this out because Unity will build them on top.

–

I know this is a very old post that might be solved but for future reference if anyone is having this problem I can almost guarantee it’s because the Text in the button or something else’s width is too large. If the text width is way bigger than the actual text it messes with the button and any other nearby buttons.

This helped me, because my UI Image was in front of the button. Thanks

–

may be you’ve disabled the Raycast Target option of your button’s Image Script
68610-untitled.png

[68614-untitled.png|68614]HI, Thanks for the answer, but unfortunately its not the case here :( it is ticked for the entire hierarchy including the buttons :|

–

I think this is the answer. But the blocking images should have raycast target unchecked. That way the click will travel straight through the image to the underlying button.

–

Right so, as you can see, there are lots of panels that are children of canvas. Also, this setting - the camera and canvas (and event system) is common in all the levels, so well, I thought of it as a good idea some time back. Also, I have to activate / deactivate lot of hints, buttons and panels from script, so this hierarchy makes it very easy. Not sure if now its causing this issue :frowning: - but then again why ? :expressionless:
The reason for z position variation is - I searched this forum for the possible reasons, and well I initially thought that some other panel might have been above the buttons, so I re-positioned everything to make sure all the panels are the stacked properly and as per the order in the game. Now, I am sure nothing is on top of buttons.

hey, try clickin on the sprite in assets,open sprite editor,there might me something ,dunno

–

It would appear my tests in LinqPAD didn't translate over to Unity. Here is a working solution: GUILayout.Label (string.Format("{0:ss} seconds {0:fff} milliseconds", System.DateTime.Parse(System.TimeSpan.FromSeconds (Time.time).ToString()))); LInqPAD showed formatting fine with my original post above, but didn't work in unity: ![LinqPAD TimeSpan Formatting][1] Working in Unity with DateTime Parse as the timespan format wouldn't function: ![Working DateTime Parse][2] [1]: http://i.imgur.com/k2niIAY.png [2]: http://i.imgur.com/Aktgccv.png

–

Well I think the suggestion to set scale of EventSystems to 1 helped me a lot. Responses of lot of buttons improved a lot. Many, still are glitchy but well atleast some improvements.

edit:

Setting the camera to Overlay mode helped a lot and looks like its working now flawlessly, however Ill continue to keep an eye out if the issue seems to return.
Thanks meat5000 for the answer :slight_smile:

Have the same issue. Canvas is set to overlay and scale is set to 1....Still no luck. The buttons are so busted atm. The button navigation doesn't work either on touchscreen.

–

I am getting the same problem but I don't know where the problem is I've got a screenshot of the UI hierarchy: [132030-screen-shot-2019-01-27-at-143623.png|132030]

–

Hi everyone I know a late answer but I was checking my UI elements and realized their actual size was bigger but due to preserving the aspect they just seemed smaller so I made it fit the actual width and height of the buttons and the problem was solved.

No problem! If this is the most helpful answer, click the "accept" button at the bottom of the answer so your question will appear as answered.

–