您的位置:首页 > 移动开发 > Unity3D

Unity实战笔记_2.登陆界面脚本编写

2016-12-23 23:07 267 查看
先简单模拟一下用户登陆的流程。功能后续再添加。

using UnityEngine;
using System.Collections;

public class LoginPanel : MonoBehaviour
{

private UIInput accInput;
private UIInput pwdInput;

// Use this for initialization
void Start ()
{
accInput = transform.Find("InputAcc").GetComponent<UIInput>();
pwdInput = transform.Find("InputPwd").GetComponent<UIInput>();
BoxCollider[] boxs = transform.GetComponentsInChildren<BoxCollider>(true);//参数为隐藏的boxcollider也可以找到
foreach (BoxCollider box in boxs)
{
UIEventListener listener = UIEventListener.Get(box.gameObject);
listener.onClick = onClick;
}
}
void onClick(GameObject click)
{
if(click.name.Equals("LoginButton"))
{
Debug.Log(string.Format("用户登录! Account:{0},Password:{1}", accInput.value, pwdInput.value));
}
}
}


重点:NGUI封装的监听事件用法。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unity