diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs index 728256bf..719d4f92 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs @@ -60,6 +60,10 @@ namespace Fungus.Script } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); + + EditorGUILayout.Separator(); + + DrawVariablesGUI(); } public void DrawSequenceGUI(FungusScript fungusScript) diff --git a/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs b/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs index b20435a4..4599980c 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusVariableListAdaptor.cs @@ -86,20 +86,20 @@ namespace Fungus.Script { FungusVariable variable = this[index].objectReferenceValue as FungusVariable; - float width1 = 60; + float width1 = 100; float width3 = 50; - float width2 = Mathf.Max(position.width - width1 - width3, 100); - - Rect typeRect = position; - typeRect.width = width1; + float width2 = Mathf.Max(position.width - width1 - width3, 60); Rect keyRect = position; - keyRect.x += width1; - keyRect.width = width2; + keyRect.width = width1; + Rect valueRect = position; + valueRect.x += width1 + 5; + valueRect.width = width2 - 5; + Rect scopeRect = position; - scopeRect.x += width1 + width2; - scopeRect.width = width3; + scopeRect.x += width1 + width2 + 5; + scopeRect.width = width3 - 5; string type = ""; if (variable.GetType() == typeof(BooleanVariable)) @@ -118,21 +118,16 @@ namespace Fungus.Script { type = "String"; } - - GUI.Label(typeRect, type); - - EditorGUI.BeginChangeCheck(); - + + FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); + string key = variable.key; - + VariableScope scope = variable.scope; + if (Application.isPlaying) { - const float w = 100; - Rect valueRect = keyRect; - keyRect.width = w - 5; - valueRect.x += w; - valueRect.width -= (w + 5); - key = EditorGUI.TextField(keyRect, variable.key); + GUI.Label(keyRect, variable.key); + if (variable.GetType() == typeof(BooleanVariable)) { BooleanVariable v = variable as BooleanVariable; @@ -153,24 +148,32 @@ namespace Fungus.Script StringVariable v = variable as StringVariable; v.Value = EditorGUI.TextField(valueRect, v.Value); } + + if (scope == VariableScope.Local) + { + GUI.Label(scopeRect, "Local"); + } + else if (scope == VariableScope.Global) + { + GUI.Label(scopeRect, "Global"); + } } else { - keyRect.width -= 5; - key = EditorGUI.TextField(keyRect, variable.key); - } - - VariableScope scope = (VariableScope)EditorGUI.EnumPopup(scopeRect, variable.scope); + EditorGUI.BeginChangeCheck(); - FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); - - if (EditorGUI.EndChangeCheck ()) - { - Undo.RecordObject(variable, "Set Variable"); + key = EditorGUI.TextField(keyRect, variable.key); + GUI.Label(valueRect, type); + scope = (VariableScope)EditorGUI.EnumPopup(scopeRect, variable.scope); - // Modify the key if it clashes with an existing variable key - variable.key = fungusScript.GetUniqueVariableKey(key, variable); - variable.scope = scope; + if (EditorGUI.EndChangeCheck ()) + { + Undo.RecordObject(variable, "Set Variable"); + + // Modify the key if it clashes with an existing variable key + variable.key = fungusScript.GetUniqueVariableKey(key, variable); + variable.scope = scope; + } } if (fungusScript != null) diff --git a/Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs b/Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs deleted file mode 100644 index c4b7b766..00000000 --- a/Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs +++ /dev/null @@ -1,71 +0,0 @@ -using UnityEngine; -using UnityEditor; - -public class SplitViewWindow : EditorWindow -{ - private Vector2 scrollPos = Vector2.zero; - float commandViewWidth; - bool resize = false; - Rect cursorChangeRect; - - public float minViewWidth = 150; - - [MenuItem("MyWindows/SplitView")] - public static void Init(){ - GetWindow(); - } - - void OnEnable() - { - commandViewWidth = minViewWidth; - cursorChangeRect = new Rect(this.position.width - commandViewWidth, 0, 4f, this.position.height); - } - - void OnGUI() - { - GUILayout.BeginHorizontal(); - DrawScriptView(); - ResizeViews(); - GUILayout.EndHorizontal(); - - Repaint(); - } - - void DrawScriptView() - { - Rect scriptViewRect = new Rect(0, 0, this.position.width - commandViewWidth, this.position.height); - - scrollPos = GUI.BeginScrollView(scriptViewRect, scrollPos, scriptViewRect); - - GUI.EndScrollView(); - } - - void ResizeViews() - { - cursorChangeRect.x = this.position.width - commandViewWidth; - cursorChangeRect.height = this.position.height; - - GUI.color = Color.grey; - GUI.DrawTexture(cursorChangeRect, EditorGUIUtility.whiteTexture); - EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeHorizontal); - - if (Event.current.type == EventType.mouseDown && cursorChangeRect.Contains(Event.current.mousePosition)) - { - resize = true; - } - if (resize) - { - commandViewWidth = this.position.width - Event.current.mousePosition.x; - commandViewWidth = Mathf.Max(minViewWidth, commandViewWidth); - commandViewWidth = Mathf.Min(this.position.width - minViewWidth, commandViewWidth); - } - if(Event.current.type == EventType.MouseUp) - { - resize = false; - } - } - - void DrawCommandView() - { - } -} \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs.meta b/Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs.meta deleted file mode 100644 index be0c66ee..00000000 --- a/Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 15f6cafd40d1c4995b33bc2e71625e7f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Fungus/FungusScript/Editor/VariablesWindow.cs b/Assets/Fungus/FungusScript/Editor/VariablesWindow.cs deleted file mode 100644 index 66607a52..00000000 --- a/Assets/Fungus/FungusScript/Editor/VariablesWindow.cs +++ /dev/null @@ -1,62 +0,0 @@ -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 = FungusScriptWindow.GetFungusScript(); - - if (fungusScript == null) - { - GUILayout.Label("No Fungus Script object selected"); - return; - } - - // Warn about conflicting global variable types - Dictionary globals = new Dictionary(); - FungusScript[] fungusScripts = GameObject.FindObjectsOfType(); - foreach (FungusScript fs in fungusScripts) - { - FungusVariable[] variables = fs.GetComponents(); - foreach (FungusVariable v in variables) - { - if (v.scope == VariableScope.Global) - { - if (globals.ContainsKey(v.key)) - { - if (globals[v.key].GetType() != v.GetType()) - { - GUIStyle errorStyle = new GUIStyle(GUI.skin.label); - errorStyle.normal.textColor = new Color(1,0,0); - GUILayout.Label("Error: Global '" + v.key + "' must use the same type in all scripts.", errorStyle); - } - } - globals[v.key] = v; - } - } - } - - scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MinWidth(Mathf.Max(position.width, 300))); - - FungusScriptEditor fungusScriptEditor = Editor.CreateEditor(fungusScript) as FungusScriptEditor; - fungusScriptEditor.DrawVariablesGUI(); - - GUILayout.EndScrollView(); - } - } - -} \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Editor/VariablesWindow.cs.meta b/Assets/Fungus/FungusScript/Editor/VariablesWindow.cs.meta deleted file mode 100644 index 7dbb7d64..00000000 --- a/Assets/Fungus/FungusScript/Editor/VariablesWindow.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 56836038c02e74487a7bf4c097b96d2b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index b2d56314..27af99b8 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ