diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index e1cf6cad..753b8221 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -80,9 +80,6 @@ namespace Fungus [Tooltip("The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.")] [SerializeField] protected string luaBindingName = "flowchart"; - [Tooltip("Draw the variable gui in the inspector.")] - [SerializeField] protected bool showVariables = true; - protected static List cachedFlowcharts = new List(); protected static bool eventSystemPresent; diff --git a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs index 9b21447e..30824776 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs @@ -30,7 +30,6 @@ namespace Fungus.EditorUtils protected SerializedProperty hideCommandsProp; protected SerializedProperty luaEnvironmentProp; protected SerializedProperty luaBindingNameProp; - protected SerializedProperty varInspectorProp; protected Texture2D addTexture; @@ -50,7 +49,6 @@ namespace Fungus.EditorUtils hideCommandsProp = serializedObject.FindProperty("hideCommands"); luaEnvironmentProp = serializedObject.FindProperty("luaEnvironment"); luaBindingNameProp = serializedObject.FindProperty("luaBindingName"); - varInspectorProp = serializedObject.FindProperty("showVariables"); addTexture = FungusEditorResources.AddSmall; } @@ -72,7 +70,6 @@ namespace Fungus.EditorUtils EditorGUILayout.PropertyField(showLineNumbersProp); EditorGUILayout.PropertyField(luaEnvironmentProp); EditorGUILayout.PropertyField(luaBindingNameProp); - EditorGUILayout.PropertyField(varInspectorProp); // Show list of commands to hide in Add Command menu ReorderableListGUI.Title(new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip)); @@ -91,15 +88,13 @@ namespace Fungus.EditorUtils serializedObject.ApplyModifiedProperties(); - if (varInspectorProp.boolValue) - { - GUILayout.Space(20); + //Show the variables in the flowchart inspector + GUILayout.Space(20); - DrawVariablesGUI(false, Screen.width - 70); - } + DrawVariablesGUI(false, Screen.width - 70); } - + public virtual void DrawVariablesGUI(bool showVariableToggleButton, int w) { serializedObject.Update(); @@ -109,6 +104,7 @@ namespace Fungus.EditorUtils if (t.Variables.Count == 0) { t.VariablesExpanded = true; + //showVariableToggleButton = true; } if (showVariableToggleButton && !t.VariablesExpanded) @@ -127,35 +123,26 @@ namespace Fungus.EditorUtils else { Rect listRect = new Rect(); - - if (t.Variables.Count > 0) + + // Remove any null variables from the list + // Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class) + for (int i = t.Variables.Count - 1; i >= 0; i--) { - // Remove any null variables from the list - // Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class) - for (int i = t.Variables.Count - 1; i >= 0; i--) + if (t.Variables[i] == null) { - if (t.Variables[i] == null) - { - t.Variables.RemoveAt(i); - } + t.Variables.RemoveAt(i); } + } - ReorderableListGUI.Title("Variables"); - VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0, w == 0 ? VariableListAdaptor.DefaultWidth : w); + ReorderableListGUI.Title("Variables"); + VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0, w == 0 ? VariableListAdaptor.DefaultWidth : w); - ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton; + ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton; - ReorderableListControl.DrawControlFromState(adaptor, null, flags); - - listRect = GUILayoutUtility.GetLastRect(); - } - else - { - GUILayoutUtility.GetRect(300, 24); - listRect = GUILayoutUtility.GetLastRect(); - listRect.y += 20; - } + ReorderableListControl.DrawControlFromState(adaptor, null, flags); + listRect = GUILayoutUtility.GetLastRect(); + float plusWidth = 32; float plusHeight = 24;