diff --git a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs index ed82b68c..de03c7d2 100755 --- a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs @@ -14,8 +14,6 @@ namespace Fungus.Script private List windowSequenceMap = new List(); - private GameObject cachedSelection; - [MenuItem("Window/Fungus Editor")] static void Init() { @@ -27,7 +25,7 @@ namespace Fungus.Script Repaint(); } - FungusScript GetFungusScript() + static public FungusScript GetFungusScript() { GameObject activeObject = Selection.activeGameObject; @@ -146,6 +144,12 @@ namespace Fungus.Script { Selection.activeGameObject = fungusScript.gameObject; } + + GUI.backgroundColor = Color.white; + if (GUILayout.Button("Show Variables")) + { + EditorWindow.GetWindow(true, "Fungus Variables"); + } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); diff --git a/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs b/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs new file mode 100644 index 00000000..3e6afcb8 --- /dev/null +++ b/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs @@ -0,0 +1,98 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Fungus.Script +{ + + public class VariablesWindow : EditorWindow + { + Vector2 scrollPos = new Vector2(); + + public void OnInspectorUpdate() + { + Repaint(); + } + + void OnGUI() + { + FungusScript fungusScript = FungusEditorWindow.GetFungusScript(); + + if (fungusScript == null) + { + GUILayout.Label("No Fungus Script object selected"); + return; + } + + bool showValues = Application.isPlaying; + + float columnWidth = (position.width - 40) / (showValues ? 3 : 2); + + scrollPos = GUILayout.BeginScrollView(scrollPos); + + GUILayout.BeginHorizontal(); + GUILayout.Label("Key", GUILayout.Width(columnWidth)); + GUILayout.Label("Type", GUILayout.Width(columnWidth)); + if (showValues) + { + GUILayout.Label("Value", GUILayout.Width(columnWidth)); + } + GUILayout.EndHorizontal(); + + GUIStyle boxStyle = new GUIStyle(GUI.skin.box); + boxStyle.margin.left = 0; + boxStyle.margin.right = 0; + boxStyle.margin.top = 0; + boxStyle.margin.bottom = 0; + + foreach (Variable variable in fungusScript.variables) + { + GUILayout.BeginHorizontal(boxStyle); + + string keyString = variable.key; + string typeString = ""; + string valueString = ""; + + switch (variable.type) + { + case VariableType.Boolean: + typeString = "Boolean"; + valueString = variable.booleanValue ? "True" : "False"; + break; + case VariableType.Integer: + typeString = "Integer"; + valueString = variable.integerValue.ToString(); + break; + case VariableType.Float: + typeString = "Float"; + valueString = variable.floatValue.ToString(); + break; + case VariableType.String: + typeString = "String"; + if (variable.stringValue.Length == 0) + { + valueString = "\"\""; + } + else + { + valueString = variable.stringValue; + } + break; + } + + GUILayout.Label(keyString, GUILayout.Width(columnWidth)); + GUILayout.Label(typeString, GUILayout.Width(columnWidth)); + if (showValues) + { + GUILayout.Label(valueString, GUILayout.Width(columnWidth)); + } + + GUILayout.EndHorizontal(); + } + GUILayout.EndScrollView(); + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs.meta b/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs.meta new file mode 100644 index 00000000..7dbb7d64 --- /dev/null +++ b/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 56836038c02e74487a7bf4c097b96d2b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: