diff --git a/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs b/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs index d187f2f6..b6a07df1 100644 --- a/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs @@ -10,7 +10,7 @@ namespace Fungus.Script [CustomEditor (typeof(AddOption))] public class AddOptionEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { AddOption t = target as AddOption; diff --git a/Assets/Fungus/Editor/FungusScript/CallEditor.cs b/Assets/Fungus/Editor/FungusScript/CallEditor.cs index 34cfc713..f3a16099 100644 --- a/Assets/Fungus/Editor/FungusScript/CallEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/CallEditor.cs @@ -9,7 +9,7 @@ namespace Fungus.Script [CustomEditor (typeof(Call))] public class CallEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { serializedObject.Update(); diff --git a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs index 002abb90..162344de 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs @@ -25,50 +25,66 @@ namespace Fungus.Script { FungusCommand t = target as FungusCommand; - Rect rect = EditorGUILayout.BeginVertical(); + GUILayout.BeginHorizontal(); + + t.expanded = EditorGUILayout.Foldout(t.expanded, t.GetType().Name); + + GUIStyle labelStyle = EditorStyles.miniLabel; + GUILayout.Label(t.GetDescription().Replace("\n", "").Replace("\r", ""), labelStyle); + + GUILayout.FlexibleSpace(); + + GUILayout.EndHorizontal(); + + if (!t.expanded) + { + return; + } GUILayout.BeginHorizontal(); - if (GUILayout.Button("Up")) + GUILayout.FlexibleSpace(); + + if (GUILayout.Button("Up", EditorStyles.miniButtonLeft)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(t); } - if (GUILayout.Button("Down")) + if (GUILayout.Button("Down", EditorStyles.miniButtonMid)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(t); } - - GUILayout.FlexibleSpace(); - + FungusScript fungusScript = t.GetFungusScript(); - + if (fungusScript != null) { - if (GUILayout.Button("Copy")) + if (GUILayout.Button("Copy", EditorStyles.miniButtonMid)) { fungusScript.copyCommand = t; } - + if (fungusScript.copyCommand != null) { - if (GUILayout.Button("Paste")) + if (GUILayout.Button("Paste", EditorStyles.miniButtonMid)) { CopyComponent(fungusScript.copyCommand, t.gameObject); } } } - - if (GUILayout.Button("Delete")) + + if (GUILayout.Button("Delete", EditorStyles.miniButtonRight)) { Undo.DestroyObjectImmediate(t); return; } + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); EditorGUILayout.Separator(); - DrawCommandInspectorGUI(); + DrawCommandGUI(); EditorGUILayout.Separator(); @@ -81,6 +97,7 @@ namespace Fungus.Script EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style); } + /* if (t.IsExecuting()) { EditorGUI.DrawRect(rect, new Color(0f, 1f, 0f, 0.25f)); @@ -89,12 +106,11 @@ namespace Fungus.Script { EditorGUI.DrawRect(rect, new Color(1f, 1f, 0f, 0.25f)); } + */ } - - EditorGUILayout.EndVertical(); } - public virtual void DrawCommandInspectorGUI() + public virtual void DrawCommandGUI() { DrawDefaultInspector(); } diff --git a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs index 67dcc700..abe96bd4 100755 --- a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs @@ -166,12 +166,7 @@ namespace Fungus.Script GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); - GUILayout.Space(15); - if (GUILayout.Button(labelText)) - { - Selection.activeGameObject = fungusScript.gameObject; - } - + GUILayout.Space(10); GUI.backgroundColor = Color.white; if (GUILayout.Button("Show Variables")) { @@ -224,21 +219,9 @@ namespace Fungus.Script Sequence sequence = windowSequenceMap[windowId]; - if (!Application.isPlaying && sequence.gameObject == Selection.activeGameObject) - { - string description = GUILayout.TextArea(sequence.description, GUILayout.ExpandWidth(true)); - if (description != sequence.description) - { - Undo.RecordObject(sequence, "Set Description"); - sequence.description = description; - } - } - else - { - GUIStyle labelStyle = new GUIStyle(GUI.skin.label); - labelStyle.wordWrap = true; - GUILayout.Label(sequence.description, labelStyle); - } + GUIStyle labelStyle = new GUIStyle(GUI.skin.label); + labelStyle.wordWrap = true; + GUILayout.Label(sequence.description, labelStyle); /* GUIStyle style = new GUIStyle(GUI.skin.button); diff --git a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs index cad8111f..7b37c535 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs @@ -75,7 +75,8 @@ namespace Fungus.Script GUILayout.FlexibleSpace(); } - if (GUILayout.Button("Create")) + if (GUILayout.Button("Create", + t.selectedSequence == null ? EditorStyles.miniButton : EditorStyles.miniButtonLeft)) { GameObject go = new GameObject("Sequence"); go.transform.parent = t.transform; @@ -96,12 +97,12 @@ namespace Fungus.Script if (t.selectedSequence != null) { - if (GUILayout.Button("Delete")) + if (GUILayout.Button("Delete", EditorStyles.miniButtonMid)) { Undo.DestroyObjectImmediate(t.selectedSequence.gameObject); t.selectedSequence = null; } - if (GUILayout.Button("Duplicate")) + if (GUILayout.Button("Duplicate", EditorStyles.miniButtonRight)) { GameObject copy = GameObject.Instantiate(t.selectedSequence.gameObject) as GameObject; copy.transform.parent = t.transform; @@ -149,20 +150,12 @@ namespace Fungus.Script } EditorGUILayout.PrefixLabel("Commands"); - + FungusCommand[] commands = sequence.GetComponents(); foreach (FungusCommand command in commands) { - if (GUILayout.Button(command.GetCommandTitle(), GUILayout.ExpandWidth(true))) - { - command.expanded = !command.expanded; - } - - if (command.expanded) - { - Editor commandEditor = Editor.CreateEditor(command); - commandEditor.OnInspectorGUI(); - } + Editor commandEditor = Editor.CreateEditor(command); + commandEditor.OnInspectorGUI(); } } diff --git a/Assets/Fungus/Editor/FungusScript/SayEditor.cs b/Assets/Fungus/Editor/FungusScript/SayEditor.cs index 71cb5290..5dab650a 100644 --- a/Assets/Fungus/Editor/FungusScript/SayEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SayEditor.cs @@ -10,7 +10,7 @@ namespace Fungus.Script [CustomEditor (typeof(Say))] public class SayEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { Say t = target as Say; diff --git a/Assets/Fungus/Editor/FungusScript/SetEditor.cs b/Assets/Fungus/Editor/FungusScript/SetEditor.cs index eb348bb4..7db41410 100644 --- a/Assets/Fungus/Editor/FungusScript/SetEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SetEditor.cs @@ -9,7 +9,7 @@ namespace Fungus.Script [CustomEditor (typeof(Set))] public class SetEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { serializedObject.Update(); diff --git a/Assets/Fungus/VisualScripting/Call.cs b/Assets/Fungus/VisualScripting/Call.cs index 04e240fa..a1a6538b 100644 --- a/Assets/Fungus/VisualScripting/Call.cs +++ b/Assets/Fungus/VisualScripting/Call.cs @@ -185,14 +185,41 @@ namespace Fungus.Script } } - public override string GetCommandTitle() + public override string GetDescription() { if (callCondition == CallCondition.CallAlways) { - return GetType().Name; + return targetSequence.name; + } + else + { + if (variable == null) + { + return "No variable selected"; + } + + string description = "If " + variable.key + " then "; + + if (onTrueSequence == null) + { + description += ""; + } + else + { + description += onTrueSequence.name; + } + description += " else "; + if (onFalseSequence == null) + { + description += ""; + } + else + { + description += onFalseSequence.name; + } + + return description; } - - return GetType().Name + "?"; } } diff --git a/Assets/Fungus/VisualScripting/FungusCommand.cs b/Assets/Fungus/VisualScripting/FungusCommand.cs index 145082c5..c7bcd0e8 100644 --- a/Assets/Fungus/VisualScripting/FungusCommand.cs +++ b/Assets/Fungus/VisualScripting/FungusCommand.cs @@ -88,9 +88,9 @@ namespace Fungus.Script public virtual void GetConnectedSequences(ref List connectedSequences) {} - public virtual string GetCommandTitle() + public virtual string GetDescription() { - return GetType().Name; + return ""; } } diff --git a/Assets/Fungus/VisualScripting/FungusScript.cs b/Assets/Fungus/VisualScripting/FungusScript.cs index 87a3a577..8b2accb8 100644 --- a/Assets/Fungus/VisualScripting/FungusScript.cs +++ b/Assets/Fungus/VisualScripting/FungusScript.cs @@ -52,10 +52,6 @@ namespace Fungus.Script return; } - #if UNITY_EDITOR - Selection.activeGameObject = sequence.gameObject; - #endif - executingSequence = sequence; sequence.ExecuteNextCommand(); } diff --git a/Assets/Fungus/VisualScripting/Say.cs b/Assets/Fungus/VisualScripting/Say.cs index 28e14c21..39e9052e 100644 --- a/Assets/Fungus/VisualScripting/Say.cs +++ b/Assets/Fungus/VisualScripting/Say.cs @@ -82,6 +82,11 @@ namespace Fungus.Script Continue(); }); } + + public override string GetDescription() + { + return "\"" + text + "\""; + } } } \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Sequence.cs b/Assets/Fungus/VisualScripting/Sequence.cs index 4aa1e174..d4eb076f 100644 --- a/Assets/Fungus/VisualScripting/Sequence.cs +++ b/Assets/Fungus/VisualScripting/Sequence.cs @@ -131,11 +131,6 @@ namespace Fungus.Script { activeCommand = null; fungusScript.executingSequence = null; - - // No more commands to run in current sequence - #if UNITY_EDITOR - Selection.activeGameObject = fungusScript.gameObject; - #endif } } } diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 0b019652..e7cb8aef 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ