参考 https://www.jianshu.com/p/e82b22a9c5eb
一、导入一张按钮图,并设置类型为Sprite (2D and UI)
必须勾上Read/Write Enabled
二、更改Image的alphaHitTestMinimumThreshold值(alpha小于此值的区域不会响应点击事件)
把下面的脚本挂在Button上
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AlphaButton : MonoBehaviour { public float alphaHitTestMinimumThreshold = 0.1f; void Awake() { this.GetComponent<Image>().alphaHitTestMinimumThreshold = alphaHitTestMinimumThreshold; } }