首页 > 代码库 > NGUI监听事件

NGUI监听事件

using UnityEngine; using System.Collections; public class UIDataHandler : MonoBehaviour { public UIInput nameInput; public UIInput psInput; public GameObject loginBtn; public GameObject registerBtn; public UILabel tipLabel; void Start () { //侦听按钮事件 UIEventListener.Get(loginBtn).onClick = clickHandler; UIEventListener.Get(registerBtn).onClick = clickHandler; } void clickHandler(GameObject go) { if(go.name=="loginButton") { Debug.Log("登录:" + nameInput.label.text + "," + psInput.label.text); tipLabel.text = "用户名:" + nameInput.label.text + ",密码:" + psInput.label.text; } if (go.name == "registerButton") { Debug.Log("注册:"+nameInput.label.text + "," + psInput.label.text); tipLabel.text = "用户名:" + nameInput.label.text + ",密码:" + psInput.label.text; } } void Update () { } }

 

http://bbs.taikr.com/thread-2003-1-1.html

NGUI监听事件