- Home /
Question by
LucasVmarrewyk · Oct 21, 2012 at 03:12 PM ·
login
login script fails for some reason
I made a login script but it automaticaly loads the next level what did I do wrong.
using UnityEngine;
using System.Collections;
public class welcom : MonoBehaviour {
static private string username = "";
bool knowYou = false;
void OnGUI ()
{
GUI.BeginGroup (new Rect(Screen.width /2f - 300,Screen.height /2f - 300,600,600));
username = GUI.TextArea(new Rect(200,100,200,25),username);
GUI.Label(new Rect(200,50,200,25), "WELCOME TO A FARMING LIFE");
GUI.Label(new Rect(170,80,300,25), "PLEASE ENTER YOU NAME THAN CLICK OK");
GUI.Button(new Rect(170,150,300,25), "ok");
{
CheckTheUserName ();
if(knowYou == true)
{
GUI.Button(new Rect(200,180,300,25), "I know you right?");
{
Application.LoadLevel(1);
}
}
else
{
PlayerPrefs.SetString("login", username);
GUI.Button(new Rect(170,220,300,25), "I have registered you");
{
Application.LoadLevel(1);
}
}
}
GUI.EndGroup ();
}
void CheckTheUserName ()
{
if(PlayerPrefs.GetString("login")== username)
{
knowYou = true;
}
}
}
Comment
Best Answer
Answer by Loius · Oct 21, 2012 at 04:08 PM
Your GUI buttons have no 'if'.
statement;
{
alwaysExecutedStatement;
}