为按钮添加音效
代码示例
using UnityEngine;
using UnityEngine.UI;
using UNIHper;
public class IdleUI : UIBase
{
// Start is called before the first frame update
private void Start()
{
this.Get<Button>("btn_start")
.WithSound() // 使用UNIHper/Settings 下默认的音效
.onClick.AddListener(() =>
{
Debug.Log("btn_start clicked");
});
this.Get<Button>("btn_start").WithSound("hit_audio"); // 使用自定义的音效
}
}
Last updated