How do i extend the area you can touch around a button

How do I go about extending the area that allows a button to be pressed outside of the size of the image.

I don’t want to increase the actual sprite size with transparent pixels.

Figured it out, use Physics2DRaycaster a camera in orthographic mode and add colliders to the ui objects instead of relying on the sprite bounds.

That’s certainly an interesting alternate approach @trooper , hadn’t considered that one.
Fantastic.

Simon, is there a better one I haven’t thought of?

I ended up grabbing the Physics2DRaycaster code and making a raycaster without RaycastAll to avoid the memory allocations. Seems to work well but I haven’t tested on mobile or in a game yet… trying to optimize as much as possible (0 allocations during runtime) before I test on mobile.

The only other real way would involve having a background transparent image with a script to pick up the click event and either route it to the button or build a new button with a bigger background. Yours was more simplistic. pears and apples :smile:

What I’ve been doing for this situation is to have the button image be null with 0 alpha and set it to the size of the clickable button area I want. The actual graphical button image I want to use would simply be a child image on that button and have the button component reference that image for transitions. Probably not so great with extra draw calls but simple to set up and use for a few cases.