- Home /
Make "polygon" collider for UI element
I have an image as a background for my UI panel. And it has complex shape. But if I try to click in some places where there are no UI elements, my objects behind UI wont react. So I assume my UI has this collider: http://take.ms/ou1jU How can I make some kind of polygon collider for my UI element so it would not block objects that are behind it, but can be seen?
Example: http://take.ms/hv1yR - I cant click on the frog, because UI blocking it.
Answer by HarshadK · Mar 25, 2015 at 02:04 PM
You can make your current UI element to just be a sprite instead of a UI element and write a script that implements IPointerClickHandler (or other similar event handlers for EventSystem) to handle the click (or other) events. This way you can add a polygon collider to your sprite and get the click events on the area covered by sprite only.
Yeah, I thought about this solution, but its kind of messy. Anyways, If I will not find solution to keep this panel as UI element, I will use this. Thanks for response.
Answer by LSPressWorks · Sep 26, 2017 at 09:15 PM
How do I setup collisions if I used the sprite as he initially suggested?
Answer by lucbloom · Oct 23, 2021 at 07:34 AM
This class might be able to help you: https://github.com/lucbloom/unity_image_with_hit_detection_on_shape
Answer by YASTitanium · Oct 23, 2021 at 09:06 AM
I have an image as a background for my UI panel. And it has complex shape. But if I try to click in some ...and also TITANIUM TV is an application that enables users to access all genres of entertainment. Such as Sports, Movies, Music, Videos, and TV shows.for more videos click on TITANIUM TV
Your answer
Follow this Question
Related Questions
Blocking and not blocking input in new uGUI 4.6 1 Answer
Collider Blocking Worldspace Canvas? 1 Answer
Detect only UI button click 3 Answers
Allow Click Through some UI Elements 1 Answer
Scrollable, clickable overworld map 0 Answers