Browse Source

Removed ShowVariables bool, just showing the variables in the fungus flowchart inspector always

Adjusted Reorderable draw logic to draw even if there are no items in there so we get it showing the variables header.
master
desktop-maesty/steve 7 years ago
parent
commit
be66286822
  1. 3
      Assets/Fungus/Scripts/Components/Flowchart.cs
  2. 43
      Assets/Fungus/Scripts/Editor/FlowchartEditor.cs

3
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<Flowchart> cachedFlowcharts = new List<Flowchart>();
protected static bool eventSystemPresent;

43
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,12 +88,10 @@ 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);
}
@ -109,6 +104,7 @@ namespace Fungus.EditorUtils
if (t.Variables.Count == 0)
{
t.VariablesExpanded = true;
//showVariableToggleButton = true;
}
if (showVariableToggleButton && !t.VariablesExpanded)
@ -128,33 +124,24 @@ namespace Fungus.EditorUtils
{
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);
ReorderableListControl.DrawControlFromState(adaptor, null, flags);
listRect = GUILayoutUtility.GetLastRect();
}
else
{
GUILayoutUtility.GetRect(300, 24);
listRect = GUILayoutUtility.GetLastRect();
listRect.y += 20;
}
listRect = GUILayoutUtility.GetLastRect();
float plusWidth = 32;
float plusHeight = 24;

Loading…
Cancel
Save