Unity自定义按钮触发区域

时间:2018-05-27 10:22:41

标签: unity3d button

我想为我的按钮设置自定义OnClick触发区域,该图标是Button对象的子项:

enter image description here

但是,按钮仅在点击它的子图像(上图中的ButtonIcon)时触发OnClick,忽略按钮本身的实际宽度和高度。

如何设置自定义触发区域?

1 个答案:

答案 0 :(得分:1)

将Panel UI元素添加为Button的子元素:

enter image description here

然后将“Source Image”精灵设置为None,将Color alpha设置为0:

enter image description here

现在您可以设置触摸区域的自定义大小!

enter image description here