Unity3d new UI: How to set button's interactable zone bigger than the attached image?
I believe the most proper way to make such button is like this:
- Create a new Button, remove default child Text.
- Set
Width
andHeight
of Button as you need for hitzone size. - Add
Vertical Layout Group
component to the Button. - Set
Padding
of theVertical Layout Group
to desirable difference between hitzone and visuals. Remove defaultSet alpha of defaultImage
component.Image
component to zero.- Put your Image as child of Button.
- Fix tint: drag (or otherwise set) the child
Image
toTarget Graphic
field ofButton
.
You need to set it up so that the image is inside a button object. Like this:
This way you can have the Button as big as you want and the Image can be any size. If you don't need the Button background image just make the color transparent in the image componenent of the Button object.
A surprisingly better way (in terms of ease and performance) is to add a text child element, even if you already have one. Leave the text empty and resize it however you like. It doesn't add any alpha.