On Pointer Enter for semi-transparent UI?

I’m trying to make a map using UI that is divided into different sections that when hovered over, they display information about that area. I was using On Pointer Enter, but I ran into a problem. On Pointer Enter assumes that the shape of the object is a rectangle, when that wasn’t the case with the map I was making. I had each section of the map as a png image displayed using UI and then put together like puzzle pieces on the map. None of the sections are perfectly rectangular. Is there a way to make it so that On Pointer Enter doesn’t include when the mouse is hovering over the transparent part of the UI image? This is the map I was using.:

I’ve put together an example for you. You’ll need to create polygon triggers and Event Triggers on them. Turn off the RayCast target on their UI component and make sure that the canvas is in Camera Space. The Camera will need to have a Physics 2D Raycaster on it. I tend to like to do this with just sprites instead because unity will do a decent job of making the polygon on a sprite, but a crap job of it on a UI image.
The setup for doing this on Sprites is about the same, you just don’t turn off raycast target on the sprite because it’s not there.

Cheers!

[81130-testpolyui.zip|81130]

The current input Module issues a simple raycast that hits the first object thats valid for its event check (Pointer Enter for example). This works great for 98% of all the applications regarding the event system. however your condition is more specialized

What I would do is write my own Input Module to override the default one that the EventSystem GameObject implements. Instead have it implement a RayCastAll sorted by (distance to camera for 3d, or by last child for canvas) which it will issue the event to the first object. that object can then validate if its truly applicable to them (pointer event compares the pointer position against the transparent pixels via script) if valid then it uses the event.

I’d recommend that Input module still pass the events to the other elements in the RaycastAll stack. Since the event is now flagged as used, those later listeners can choose to ignore the event call and not highlight. this way enables only the first valid element to take the event by default, but also allows you to optionally chain multiple elements to using the same event raycast if wanted.