给游戏添加一个假的登陆机制
主要功能有:用户名和密码不能为空就可以登陆
直接上代码
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("登陆失败");
}
}
}