我正在尝试创建一个注册场景。当用户输入无效的姓名、电子邮件和/或密码时,我想显示三个面板。我在开始时隐藏了面板。这样可行。但是,当我输入无效信息并单击按钮时,面板不会显示。当validName
、validEmail
和validPassword
为假时,它会进入 ShowNamePanel() 并卡住。
我的代码有什么问题?
public GameObject namePanel;
public GameObject emailPanel;
public GameObject passwordPanel;
public void Start ()
{
HideNamePanel ();
HideEmailPanel ();
HidePasswordPanel ();
}
public void ButtonClick ()
{
Debug.Log ("1. Button clicked.");
CreateUser ();
}
/*
* Sends post request to create new user if name, email, and
* password are valid.
*/
public void CreateUser ()
{
validName = IsValidName (username);
validEmail = IsValidEmailAddress (email);
validPW = IsValidPassword (password);
//validNewUserCombo = IsValidNewUserCombo (email, password);
if (validName && validEmail && validPW) {
Debug.Log ("6. VALID INPUTS");
CallAPI ();
} else {
Debug.Log ("8. INVALID INPUTS");
if (validName == false) {
ShowNamePanel ();
}
if (validEmail == false) {
ShowEmailPanel ();
}
if (validPW == false) {
ShowPasswordPanel ();
}
}
}
public void ShowNamePanel() {
Debug.Log ("shownamepanel");
namePanel.SetActive (true);
}
public void HideNamePanel() {
namePanel.SetActive (false);
}
public void ShowEmailPanel() {
Debug.Log ("showemailpanel");
emailPanel.SetActive (true);
}
public void HideEmailPanel() {
emailPanel.SetActive (false);
}
public void ShowPasswordPanel() {
Debug.Log ("showpasswordpanel");
passwordPanel.SetActive (true);
}
public void HidePasswordPanel() {
passwordPanel.SetActive (false);
}