void onTerminalGUI()
    {
        scrollPos = GUILayout.BeginScrollView(scrollPos, false, false, GUIStyle.none, GUI.skin.verticalScrollbar);

        GUILayout.Label("Edit Screen", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();

        string[] screenSelect = terminalData.screens.Select(s => s.id).ToArray();

        screenIndex = EditorGUILayout.Popup("Select screen to edit:", screenIndex, screenSelect);
        if (GUILayout.Button("+"))
        {
            state = windowState.creatingScreen;
        }
        EditorGUILayout.EndHorizontal();

        onScreenCreateGUI();

        TScreen screenEdit = terminalData.screens.Find(s => s.index == screenIndex);

        onScreenEditGUI(screenEdit);

        GUILayout.EndScrollView();

        if (state == windowState.loaded)
        {
            GUILayout.Space(30);

            if (screenEdit != null)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Generate Game Objects for screen " + screenEdit.id))
                {
                    screenEdit.buildGameObjects(screenPrefabPath, optionPrefabPath);
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Generate all Game Objects for terminal " + terminalData.id))
            {
                terminalData.generateGameScreens(screenPrefabPath, optionPrefabPath);
            }


            if (GUILayout.Button("Generate all VRCTriggers for terminal " + terminalData.id))
            {
                terminalData.generateGameTriggers();
            }
            GUI.enabled = true;
        }
    }
    void loadTerminalFromFile()
    {
        // Load terminal from file data
        TerminalObject gameTerminal = terminal.gameObject.GetComponent <TerminalObject>();

        terminalData = TerminalData.loadTerminalFromFile(gameTerminal);

        if (terminalData == null)
        {
            return;
        }

        state = windowState.loaded;
    }
    void OnGUI()
    {
        UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(TerminalDialog.currentScene);

        GUILayout.Label("Specify Prefabs to use:", EditorStyles.boldLabel);
        screenPrefabPath = (string)EditorGUILayout.TextField("Path to Screen Prefab", screenPrefabPath);
        optionPrefabPath = (string)EditorGUILayout.TextField("Path to Option Prefab", optionPrefabPath);
        GUILayout.Label("Drag Terminal From Scene", EditorStyles.boldLabel);
        terminal = (GameObject)EditorGUILayout.ObjectField("Terminal Object:", terminal, typeof(GameObject), true);

        // If player changes terminal in the middle of editing
        if (terminal != currentTerminal)
        {
            currentTerminal = terminal;
            this.state      = windowState.init;
        }

        if (terminalData != null)
        {
            EditorGUILayout.LabelField("TerminalID", terminalData.id);
        }

        if (terminal != null)
        {
            if (state == windowState.init)
            {
                loadTerminalFromFile();
            }

            onTerminalGUI();
            GUILayout.Label("Save scene to save all terminal dialog settings.", EditorStyles.boldLabel);
            return;
        }

        GUILayout.Label("Please add the Terminal component to your game object and give it an ID", EditorStyles.wordWrappedLabel);
        resetGUI();
    }
 void resetNewScreen()
 {
     state       = windowState.loaded;
     newScreenID = null;
 }
 void resetGUI()
 {
     state        = windowState.init;
     terminalData = null;
     terminal     = null;
 }