bool FieldGUI(int i)
    {
        GUILayout.Label("", GUILayout.Width(10));
        EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(200) });

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Additional Field " + i, EditorStyles.boldLabel);

        if (GUILayout.Button("Remove"))
        {
            additionalFields.Remove(additionalFields [i]);
            return(true);
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Field Name:", GUILayout.Width(100));
        additionalFields [i].name = EditorGUILayout.TextField("", additionalFields[i].name, GUILayout.Width(100));
        EditorGUILayout.EndHorizontal();

        additionalFields [i].type = (AS_MySQLFieldType)EditorGUILayout.EnumPopup("Field Type: ", additionalFields [i].type);


        additionalFields [i].mustBeUnique = EditorGUILayout.Toggle("Must be Unique: ", additionalFields [i].mustBeUnique);
        additionalFields [i].isRequired   = EditorGUILayout.Toggle("Is Required: ", additionalFields [i].isRequired);


        GUILayout.Label("Comment:");
        additionalFields [i].comment = EditorGUILayout.TextField("", additionalFields [i].comment);

        if (additionalFields [i].type == AS_MySQLFieldType.UNSPECIFIED)
        {
            GUILayout.Label("Type can not be UNSPECIFIED!", EditorStyles.boldLabel, GUILayout.Width(200));
            fieldsOk = false;
        }
        else
        {
            fieldsOk &= AS_Setup.ValueCheck("Name", i, additionalFields.ToArray(), 200);
        }

        EditorGUILayout.EndVertical();
        GUILayout.Label("", GUILayout.Width(10));

        return(false);
    }
    void InitializeDatabase()
    {
        if (!fieldsOk)
        {
            initializeDbMessage = "Please check your fields for errors";
            AS_PopUpWindow.ShowWindow("Error", initializeDbMessage);
            return;
        }

        string errorMessage = AS_Setup.InitializeDatabase(additionalFields.ToArray());

        if (errorMessage == "")
        {
            AS_PopUpWindow.ShowWindow("Success!", "The Database was Initialized successfully.\nYou can now load the Demo Scene!", this, AS_SetupState.Done);
        }
        else if (errorMessage.ToLower().Contains("credentials"))
        {
            AS_PopUpWindow.ShowWindow("Error", errorMessage, this, AS_SetupState.CredentialsAndPreferences);
        }
    }
    void SetupPHPScripts(string _phpScriptsLocation)
    {
        if (!credentialsOk)
        {
            initializeDbMessage = "Please check your credentials for errors";
            AS_PopUpWindow.ShowWindow("Error", initializeDbMessage);
            return;
        }

        AS_Credentials.Save();
        AS_Preferences.Save();

        string errorMessage = AS_Setup.Setup(_phpScriptsLocation);

        if (errorMessage == "")
        {
            AS_PopUpWindow.ShowWindow("Success!", "The PHP Scripts were successfully set up.\nYou can now Initialize the Database!", this, AS_SetupState.Fields);
        }
        else
        {
            AS_PopUpWindow.ShowWindow("Error", errorMessage);
        }
    }
    void PreferencesGUI()
    {
        GUILayout.Label("Preferences", EditorStyles.boldLabel);

        // Mandatory Prefs

        AS_Preferences.askUserForEmail        = EditorGUILayout.Toggle("Ask User's Email Address", AS_Preferences.askUserForEmail);
        AS_Preferences.requireEmailActivation = EditorGUILayout.Toggle("Require Email Activation", AS_Preferences.requireEmailActivation);
        AS_Preferences.enablePasswordRecovery = EditorGUILayout.Toggle("Allow Password Recovery", AS_Preferences.enablePasswordRecovery);

        // Extra Prefs
        GUILayout.Label("", GUILayout.Height(8));
        EditorGUILayout.BeginToggleGroup("Outgoing Email Account:", AS_Preferences.requireEmailActivation | AS_Preferences.enablePasswordRecovery);
        EditorGUILayout.BeginHorizontal();
        AS_Credentials.emailAccount = EditorGUILayout.TextField("", AS_Credentials.emailAccount, GUILayout.Width(300));
        if (AS_Preferences.requireEmailActivation | AS_Preferences.enablePasswordRecovery)
        {
            credentialsOk &= AS_Setup.ValueCheck("Email Account", AS_Credentials.emailAccount, 250);
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndToggleGroup();
    }