Basically this is the code to test your theory. I also noticed my print out “continue button clicked” isn’t working.
void OnGUI() {
GUI.backgroundColor = Color.black;
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),LoginBackground,ScaleMode.StretchToFill, false, 0.0f);
GUI.Label(new Rect(Screen.width/2-250,Screen.height/2-250,500,250),"Username:", LoginStyle);
Username = GUI.TextField(new Rect(Screen.width/2-250,Screen.height/2-80,500,50), Username, 10, LoginTextBox);
GUI.Label(new Rect(Screen.width/2-250,Screen.height/2-50,500,250),"Password:", LoginStyle);
Password = GUI.TextField(new Rect(Screen.width/2-250,Screen.height/2+120,500,50), Password, 10, LoginTextBox);
if (GUI.Button(new Rect(Screen.width/2-150,Screen.height/2+200,300,50),"Login:", LoginButton))
{
//CheckLogin();
StartCoroutine(CheckLogin());
}
if (doWindow0 == true)
{
GUI.Window (0, new Rect (Screen.width/2-700,Screen.height/2-100,400,120), DoMyWindow, "Notice:");
}
}
void DoMyWindow (int windowID) {
GUI.Label(new Rect (10, 20, 800, 40), formText);
if (gotonextscene == true)
{
if (GUI.Button (new Rect (10,80,100,20), "Continue"))
{
Application.LoadLevel("CharacterSelect");
print("Continue button clicked");
doWindow0 = false;
}
}
else if(gotonextscene == false)
{
if (GUI.Button (new Rect (10,80,100,20), "Close"))
{
doWindow0 = false;
}
}
}
IEnumerator CheckLogin()
{
url = "http://redlightlife.tk/scripts/checklogin.php?username=" + WWW.EscapeURL(Username) + "&password=" + WWW.EscapeURL(Password);
w = new WWW(url);
yield return w;
Debug.Log("Downloaded");
if (w.error != null)
{
print(w.error);
}
if (w.error == null)
{
formText = w.text;
w.Dispose();
print(formText);
doWindow0 = true;
print(doWindow0);
StopAllCoroutines();
if (formText == "Login success. Click the continue button to continue to the character selection screen.")
gotonextscene = true;
if (formText == "Username or password is wrong. Please try again.")
gotonextscene = false;
}
}