Okay here is the whole script:
#pragma strict
//Variablen
private var username : String = ""; //Saves the username of the user
private var password : String = ""; //Saves the password of the user
private var serverIP : String = ""; //ServerIP where we will connect to
private var serverPassword : String = "";
private var email : String =""; //Whats your mail?
private var loginStatus : String = "Kontaktiere Server"; //Display Current Login Status
private var mainMenue : boolean = true; //Show MainMenue?
private var mainMenueMultiplayer : boolean = false; //Show MainMenueMultiplayer?
private var loginMenue : boolean = false; //Show LoginPopup?
private var optionMenue : boolean = false; //Show Options?
private var registrationMenue : boolean = false; //Show Registraion?
private var mainMenueServerIP : boolean = false; //Show Server IP Popup
private var FullScreen : boolean = Screen.fullScreen; //Checking if FullScreen is using
private var connectionStatus : String = "Status"; //Connection Status while connecting
private var registrationUnsucessfullError : String = "";
private var registrationUnsucessfullMenue : boolean = false;
private var registrationSucessfull : boolean = false;
private var registrationSucessfullMenue : boolean = false;
function OnGUI(){
if(mainMenue == true){
GUILayout.BeginArea(Rect(Screen.width/2-75,Screen.height/2-100, 150,200));
GUILayout.BeginVertical();
//Start Singleplayer
if(GUILayout.Button("Einzelspieler")){Debug.Log("Singleplayer started");}
//Show Multiplayer Menue
if(GUILayout.Button("Mehrspieler")){ShowMainMenueServerIp();}
//Show Options
if(GUILayout.Button("Optionen")){ShowMainMenueOptions();}
//Quit Button
if(GUILayout.Button("Beenden")){Application.Quit();}
GUILayout.EndVertical();
GUILayout.EndArea();
}
else if (mainMenueServerIP == true){
GUILayout.BeginArea(Rect(Screen.width/2-75,Screen.height/2-100, 150,200));
GUILayout.BeginVertical();
//Connection Status
GUILayout.Box(connectionStatus);
//ServerIp
GUILayout.Box("Server IP");
serverIP = GUILayout.TextField(serverIP, 15);
GUILayout.Box("Passwort");
serverPassword = GUILayout.PasswordField(serverPassword,"*"[0], 15);
//Connect!
if(GUILayout.Button("Verbinden")){connectionStatus = "Verbinde...";
Network.useNat = false;
Network.Connect(serverIP, 25000, serverPassword);}
if(GUILayout.Button("Zurück")){
ShowMainMenue();
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
else if(mainMenueMultiplayer == true){
GUILayout.BeginArea(Rect(Screen.width/2-75,Screen.height/2-125, 150, 250));
GUILayout.BeginVertical();
//Username
GUILayout.Box("Username");
username = GUILayout.TextField(username, 15);
//Password
GUILayout.Box("Password");
password = GUILayout.PasswordField(password,"*"[0], 15);
//Login Button
if(GUILayout.Button("Login")){StartLogin();}
//Registration Button
if(GUILayout.Button("Account erstellen")){StartRegistration();}
//BackToMainMenue
if(GUILayout.Button("Zurück")){Network.Disconnect();
ShowMainMenueServerIp();}
//Quit Button
if(GUILayout.Button("Abbrechen")){Network.Disconnect();
ShowMainMenue();}
GUILayout.EndVertical();
GUILayout.EndArea();
}
else if(loginMenue == true){
//Login Popup
GUILayout.Window(0, Rect(Screen.width/2-75,Screen.height/2-20, 150, 100) , LoginWindow, "Loginversuch");
}
else if(optionMenue == true){
//Option Popup
GUILayout.Window(1, Rect(Screen.width/2-75,Screen.height/2-100, 150,200), OptionWindow, "Optionen");
}
else if(registrationMenue == true){
//Registration Popup
GUILayout.Window(2, Rect(Screen.width/2-76,Screen.height/2-100, 150,200), RegistrationWindow, "Account erstellen");
}
else if(registrationUnsucessfullMenue == true){
GUILayout.Window(3, Rect(Screen.width/2-76, Screen.height/2-100, 150,200), RegistrationUnsucessfullWindow, "Fehler");
}
else if(registrationSucessfullMenue == true){
GUILayout.Window(4, Rect(Screen.width/2-76, Screen.height/2-100,150,200), RegistrationSucessfullWindow, "Erfolgreich");
}
else{Debug.Log("Error cant find any Popup Window");
}
}
function Update(){
//Check if Enter or KeyPadEnter is pressed to start/cancel login
if (Input.GetKeyDown (KeyCode.Return) || Input.GetKeyDown (KeyCode.KeypadEnter)){
if(loginMenue == true){CancelLogin();}
else if(mainMenueMultiplayer == true){StartLogin();}
}
}
function LoginWindow(windowID : int){
//Login Window Popup while checking account/connection
GUILayout.BeginVertical();
GUILayout.Box(loginStatus);
if (GUILayout.Button ("Abbrechen")){CancelLogin();}
GUILayout.EndVertical();
}
function OptionWindow(windowID : int){
GUILayout.BeginVertical();
FullScreen = GUILayout.Toggle(FullScreen, "Vollbild");
if (GUILayout.Button ("Übernehmen")){Screen.fullScreen = FullScreen;}
if (GUILayout.Button ("Schließen")){CloseOptions();}
GUILayout.EndVertical();
}
function RegistrationWindow(windowID : int){
GUILayout.BeginVertical();
//Username
GUILayout.Box("Username");
username = GUILayout.TextField(username, 15);
//Password
GUILayout.Box("Password");
password = GUILayout.PasswordField(password,"*"[0], 15);
//Email
GUILayout.Box("Email");
email = GUILayout.TextField(email, 30);
if(GUILayout.Button("Registrieren")){
networkView.RPC("CreateAccount", RPCMode.Server, username, password, email);
}
//Cancel Registration
if(GUILayout.Button("Abbrechen")){
username = "";
password = "";
email = "";
ShowMainMenueMultiplayer();}
GUILayout.EndVertical();
}
function ShowMainMenueMultiplayer(){
mainMenueServerIP = false;
mainMenueMultiplayer = true;
registrationMenue = false;
mainMenue = false;
}
function ShowMainMenueServerIp(){
mainMenue = false;
mainMenueServerIP = true;
}
function ShowMainMenue(){
//Shows the mainMenue
mainMenue = true;
mainMenueMultiplayer = false;
}
function ShowMainMenueOptions(){
mainMenue = false;
optionMenue = true;
}
function StartLogin(){
//Opens Login Popup, Close Main Menue Window
mainMenueMultiplayer = false;
loginMenue = true;
Debug.Log("Starte Login");
}
function StartRegistration(){
mainMenueMultiplayer = false;
registrationMenue = true;
registrationUnsucessfullMenue = false;
Debug.Log("Starte Registration");
}
function RegistrationSucessfull(){
Debug.Log("erfolgreich");
registrationMenue = false;
registrationSucessfullMenue = true;
}
function RegistrationSucessfullWindow(windowID : int){
GUILayout.BeginVertical();
GUILayout.Box("Registration Erfolgreich");
if (GUILayout.Button ("Zurück")){ShowMainMenueMultiplayer();}
GUILayout.EndVertical();
}
function RegistrationUnsucessfullWindow(windowID : int){
GUILayout.BeginVertical();
GUILayout.Box(registrationUnsucessfullError);
if (GUILayout.Button ("Zurück")){StartRegistration();}
GUILayout.EndVertical();
}
function RegistrationUnsucessfull(status : int){
registrationMenue = false;
registrationUnsucessfullMenue = true;
if(status == 0){
registrationUnsucessfullError = "Es ist ein unbekannter Serverfehler aufgetreten";
}
if(status == 2){
registrationUnsucessfullError = "Username existiert bereits";
}
}
function CancelLogin(){
//Cancel Login, show MainMenue Close Login popup
mainMenueMultiplayer = true;
loginMenue = false;
Debug.Log("Loginversuch abgebrochen");
}
function CloseOptions(){
//Close Options
mainMenue = true;
optionMenue = false;
}
function OnFailedToConnect(error: NetworkConnectionError)
{
connectionStatus = error.ToString();
}
function OnConnectedToServer() {connectionStatus = "Status";
ShowMainMenueMultiplayer();}
/*
@RPC
function CreateAccount (username : String, password : String, email : String) {}
@RPC
function CreationStatus (status : int){
//Successfull
if(status == 1){
RegistrationSucessfull();
}
}
*/