private void editorGUI(bool removeButton) { EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins); // Display the description of the Condition. string title = ""; for (int i = 0; i < condition.description.Length && i < 20; i++) { title += condition.description[i]; } if (condition.description.Length > title.Length) { title += "..."; } condition.isExpanded = EditorGUILayout.Foldout(condition.isExpanded, new GUIContent(title), true, EditorStyles.foldout); EditorGUI.BeginDisabledGroup(true); EditorGUI.indentLevel += 7; EditorGUILayout.ToggleLeft("is satisfied?", condition.isSatisfied, GUILayout.MinWidth(0)); EditorGUI.indentLevel -= 7; EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(Application.isPlaying); // Display a button showing a '-' that if clicked removes this Condition from the AllConditions asset. if (removeButton && EditorTools.createListButton("-", true, GUILayout.Width(conditionButtonWidth))) { AllConditionsEditor.RemoveCondition(condition); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); if (condition.isExpanded) { EditorGUI.indentLevel += 1; EditorGUILayout.LabelField("Condition Name"); EditorGUI.indentLevel -= 1; EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins); condition.description = EditorGUILayout.TextField(condition.description); if (GUILayout.Button(" Rename ", GUILayout.ExpandWidth(false))) { condition = ModifyConditionName(condition); // Mark the AllConditions asset as dirty so the editor knows to save changes to it when a project save happens. EditorUtility.SetDirty(AllConditions.Instance); // Recreate the condition description array with the new added Condition. AllConditionsEditor.SetAllConditionDescriptions(); AssetDatabase.SaveAssets(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); EditorGUILayout.LabelField("Editor Description"); condition.editorDescription = EditorGUILayout.TextArea(condition.editorDescription, EditorStyles.textArea, GUILayout.Height(EditorGUIUtility.singleLineHeight * 5)); EditorGUILayout.EndVertical(); GUILayout.Space(5); } EditorGUILayout.EndVertical(); }