在ngui中已经使用UIEventTrigger方法来代替UIButtonMessage方法,实现脚本回调。
定义一个脚本,
using System.Collections;
public class PressedButtonDelegate : MonoBehaviour {
private UIButton button;
private bool pressed;
// Use this for initialization
void Start () {
button = this.GetComponent<UIButton> ();
}
// Update is called once per frame
void Update () {
if (pressed) {
Debug.Log ("pressing " + Time.time);
}
}
public void OnPressed(){
pressed = true;
Debug.Log ("pressed " + Time.time);
}