How to click on irregular buttons in new ui

Hi

i have some very irregular button forms that are overlapping with there bounding boxes.
So clicking on them is not working as expected (because of overlapping areas).

Perfect would be if i have a way to say “test alpha” for raycast or create better pixel perfect colliders.
But i have no idea what the ideal/preferred way would be

Greetings
Thomas

Polygon Collider 2D

And there’s this:

http://forum.unity3d.com/threads/none-rectangle-shaped-button.263684/#post-1744521

I also faced this situation when i have angular button. I Solved it by using PolygonCollider2D component, but the problem is, still there were overlapping areas in the angular buttons. To fix this I edited polygon collider component from inspector. There is also a possibility to detect which buttons were touched using Physics2D.OverlapAreaAll and find the most appropriate one based on criteria. But i personally feel its too hard to go with it if you can easily edit the collider component, since it is one time effort so it will not cost for performance each time as in the other case i discussed.

Hope it helps!

Hi i now found the AlphaRaycaster
it does exactly what i need and is already existing code.
Well worth the money :slight_smile:

If your button relies on an image to detect the click (with the RaycastTarget option checked), you can adjust the value of a threshold which specifies the minimum alpha a pixel must have for the event to considered a “hit” on the Image. See the documentation : Image.alphaHitTestMinimumThreshold