public void SimplePromptGUI(bool cyclicAllowed = true) { GUIContent label = new GUIContent("Prompt Text (Max 30 chararcters)", "Text displayed when a player can interact with this object."); EditorGUI.BeginChangeCheck(); GUIStyle textAreaStyle = new GUIStyle(GUI.skin.textArea); GUILayout.Label(label); string _firstPrompt = GUILayout.TextArea(prompt.firstPrompt, 30, textAreaStyle, GUILayout.Height(18), GUILayout.Width(EditorGUIUtility.currentViewWidth - 50), GUILayout.ExpandWidth(false)); if (EditorGUI.EndChangeCheck()) { // first prompt was edited Undo.RecordObject(prompt, "Change Prompt"); prompt.firstPrompt = _firstPrompt; } if (string.IsNullOrEmpty(prompt.firstPrompt.Trim())) { PrairieGUI.hintLabel("No prompt will be displayed in game."); prompt.isCyclic = false; // don't allow for a cycle if the first prompt is empty return; } if (!cyclicAllowed) { return; } // guard statement GUIContent cyclicLabel = new GUIContent("Cyclic Prompt", "Does this prompt have two cycling values? (i.e. open, close)"); EditorGUI.BeginChangeCheck(); bool _isCyclic = EditorGUILayout.Toggle(cyclicLabel, prompt.isCyclic); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(prompt, "Modify Prompt"); prompt.isCyclic = _isCyclic; } if (prompt.isCyclic) { GUIContent secondLabel = new GUIContent("Second Prompt", "Second prompt to display, will toggle between this and first prompt."); GUILayout.Label(secondLabel); EditorGUI.BeginChangeCheck(); string _secondPrompt = GUILayout.TextArea(prompt.secondPrompt, 30, textAreaStyle, GUILayout.Height(18), GUILayout.Width(EditorGUIUtility.currentViewWidth - 50), GUILayout.ExpandWidth(false)); if (EditorGUI.EndChangeCheck()) { // second prompt was edited Undo.RecordObject(prompt, "Change Prompt"); prompt.secondPrompt = _secondPrompt; } if (string.IsNullOrEmpty(prompt.secondPrompt.Trim())) { PrairieGUI.hintLabel("Second prompt will be ignored."); } } }
public void SimplePromptGUI(bool cyclicAllowed = true) { GUIContent label = new GUIContent("Prompt Text", "Text displayed when a player can interact with this object."); EditorGUI.BeginChangeCheck(); string _firstPrompt = EditorGUILayout.TextField(label, prompt.firstPrompt); if (EditorGUI.EndChangeCheck()) { // first prompt was edited Undo.RecordObject(prompt, "Change Prompt"); prompt.firstPrompt = _firstPrompt; } if (string.IsNullOrEmpty(prompt.firstPrompt.Trim())) { PrairieGUI.hintLabel("No prompt will be displayed in game."); prompt.isCyclic = false; // don't allow for a cycle if the first prompt is empty return; } if (!cyclicAllowed) { return; } // guard statement GUIContent cyclicLabel = new GUIContent("Cyclic Prompt", "Does this prompt have two cycling values? (i.e. open, close)"); EditorGUI.BeginChangeCheck(); bool _isCyclic = EditorGUILayout.Toggle(cyclicLabel, prompt.isCyclic); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(prompt, "Modify Prompt"); prompt.isCyclic = _isCyclic; } if (prompt.isCyclic) { GUIContent secondLabel = new GUIContent("Second Prompt", "Second prompt to display, will toggle between this and first prompt."); EditorGUI.BeginChangeCheck(); string _secondPrompt = EditorGUILayout.TextField(secondLabel, prompt.secondPrompt); if (EditorGUI.EndChangeCheck()) { // second prompt was edited Undo.RecordObject(prompt, "Change Prompt"); prompt.secondPrompt = _secondPrompt; } if (string.IsNullOrEmpty(prompt.secondPrompt.Trim())) { PrairieGUI.hintLabel("Second prompt will be ignored."); } } }