using UnityEngine; using UnityEngine.UI; /// /// 不规则区域Button /// [RequireComponent(typeof(RectTransform))] [RequireComponent(typeof(Image))] public class IrregulaButton : MonoBehaviour { [Tooltip("设定Sprite响应的Alpha阈值")] [Range(0, 0.5f)] public float alpahThreshold = 0.5f; private void Awake() { var image = this.GetComponent(); if (null != image) { image.alphaHitTestMinimumThreshold = alpahThreshold; } } }