在工作种可能会用到不规则的按钮,下面给大家介绍一下不规则按钮的制作方法。

1、创建一个工程

不规则按钮

2、创建一个按钮

不规则按钮

3、修改按钮上图片的格式(我在网上随意找了一个多边形的图片)

不规则按钮

4、把上边这个图片拖到对应的按钮上边,创建一个脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 不规则按钮
/// </summary>
public class Button : MonoBehaviour {
    public Image Images;
// Use this for initialization
void Start () {
        Images.alphaHitTestMinimumThreshold = 0.1f;
}
    /// <summary>
    /// 点击按钮
    /// </summary>
    public void Btn()
    {
        Debug.Log(111111111);
    }
// Update is called once per frame
void Update () {

}

}

5、把脚本挂在按钮上边,然后为按钮添加点击事件

不规则按钮

点击就可以实现了

相关文章: