- 最后登录
- 2019-12-25
- 注册时间
- 2012-8-24
- 阅读权限
- 90
- 积分
- 71088
 
- 纳金币
- 52352
- 精华
- 343
|
给游戏添加一个假的登陆机制
主要功能有:用户名和密码不能为空就可以登陆
直接上代码
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LoginGame : MonoBehaviour {
public Text username;
public Text password;
// Use this for initialization
void Start () {
username = GameObject.Find("LoginGame/Panel/UserName/Text").GetComponent<Text>();
password = GameObject.Find("LoginGame/Panel/PassWord/Text").GetComponent<Text>();
print("username.text=" + username.text);
}
void Update()
{
print("ss" + username.text.IndexOf(" "));//检查是否有空格小于0 就有空格
}
public void LogainNewGame()
{
if ((username.text != string.Empty &&username.text.IndexOf(" ") < 0)&& password.text != string.Empty)
{
print("登陆成功");
}
else
{
print("登陆失败");
}
}
}
|
|