using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MyTest : MonoBehaviour
{
public Transform[] myBtn; //对应的Button按钮数组
void Start()
{
Button btn;
for (int i = 0; i < myBtn.Length; i++)
{
btn = myBtn[i].GetComponent<Button>();
btn.onClick.AddListener(delegate()
{
this.OnClick(myBtn[i]);
});
}
}
private void OnClick(Transform trans)
{
switch (trans.name)
{
case "BtnPlay":
break;
default: break;
}
}
}
时间: 2024-11-05 22:53:04