【发布时间】:2015-12-20 15:23:23
【问题描述】:
我正在做一个登录系统,当用户输入用户名或密码时,它应该通过 debug.log 在控制台中显示一条消息。
我正在为不同脚本文件中的用户名和密码编写脚本。
这里的用户名脚本:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Username : MonoBehaviour {
public string username;
public void WritingUsername()
{
// store the input from the user in the username string
username = transform.Find ("UsernameInputField/Text").GetComponent<InputField>().text;
Debug.Log (username);
}
}
密码脚本在这里:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Password : MonoBehaviour {
public string password;
public void WritingPassword()
{
// store the input from the user in the username string
password = transform.Find ("PasswordInputField/Text").GetComponent<InputField>().text;
Debug.Log (password);
}
}
这里的层次结构:
有什么问题吗?
【问题讨论】:
-
writing的电话是什么? -
我已经复制过去了,现在你说我没有更改密码中的写入功能,但我的想法是分别制作密码和用户名代码,然后在按下登录按钮时它调用 2 个脚本,这 2 个函数并验证它们,明白吗?
标签: c# unity3d textfield hierarchy