diff --git a/Assets/Fungus/Editor/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusEditorWindow.cs index f0178c0b..10064963 100755 --- a/Assets/Fungus/Editor/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusEditorWindow.cs @@ -59,6 +59,25 @@ public class FungusEditorWindow : EditorWindow return; } + string labelText = sequenceController.name; + if (Application.isPlaying) + { + if (sequenceController.activeSequence == null) + { + labelText += ": Idle"; + } + else + { + labelText += ": Active"; + } + } + + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(labelText); + GUILayout.Space(30); + GUILayout.EndHorizontal(); + // BeginScrollView lets you specify a region that 'looks into' a much larger area. In this case, we create a canvas // 1000px X 1000px in size that's constrained to the same region as the EditorWindow. If the scrollbars are modified, // the new values are stored in the Vector2 that's returned. @@ -145,7 +164,7 @@ public class FungusEditorWindow : EditorWindow { GUI.backgroundColor = Color.red; } - else if (command.IsExecuting()) + else if (ShouldHighlight(command)) { GUI.backgroundColor = Color.yellow; } @@ -172,10 +191,10 @@ public class FungusEditorWindow : EditorWindow FungusCommand[] commands = sequence.GetComponentsInChildren(); foreach (FungusCommand command in commands) { - bool isExecuting = command.IsExecuting(); + bool highlight = ShouldHighlight(command); - if (highlightedOnly && !isExecuting || - !highlightedOnly && isExecuting) + if (highlightedOnly && !highlight || + !highlightedOnly && highlight) { continue; } @@ -202,7 +221,7 @@ public class FungusEditorWindow : EditorWindow pointB = p2; Color color = Color.grey; - if (command.IsExecuting()) + if (highlight) { color = Color.yellow; } @@ -211,4 +230,9 @@ public class FungusEditorWindow : EditorWindow } } } + + bool ShouldHighlight(FungusCommand command) + { + return (command.IsExecuting() || (FungusCommandEditor.selectedCommand == command)); + } } diff --git a/Assets/Fungus/Editor/SequenceControllerEditor.cs b/Assets/Fungus/Editor/SequenceControllerEditor.cs new file mode 100644 index 00000000..a14f9efe --- /dev/null +++ b/Assets/Fungus/Editor/SequenceControllerEditor.cs @@ -0,0 +1,22 @@ +using UnityEditor; +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using Fungus; + +[CustomEditor (typeof(SequenceController))] +public class SequenceControllerEditor : Editor +{ + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + if (GUILayout.Button("Open Fungus Editor")) + { + EditorWindow.GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor"); + } + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } +} \ No newline at end of file diff --git a/Assets/Fungus/Editor/SequenceControllerEditor.cs.meta b/Assets/Fungus/Editor/SequenceControllerEditor.cs.meta new file mode 100644 index 00000000..660bd65a --- /dev/null +++ b/Assets/Fungus/Editor/SequenceControllerEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0444d16cc20de47878a9b392aea6a4a2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Fungus/Tests/Sequence/SequenceTest.unity b/Assets/Fungus/Tests/Sequence/SequenceTest.unity index 846c5226..cedfc0e9 100644 Binary files a/Assets/Fungus/Tests/Sequence/SequenceTest.unity and b/Assets/Fungus/Tests/Sequence/SequenceTest.unity differ diff --git a/Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs b/Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs index 2ecd5b47..53ccb729 100644 --- a/Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs +++ b/Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs @@ -8,7 +8,7 @@ public class SequenceTestRoom : Room void OnEnter() { - sequenceController.ExecuteSequence(sequenceController.activeSequence); + sequenceController.Execute(); /* Sequence s = GetComponent(); diff --git a/Assets/Fungus/VisualScripting/Sequence.cs b/Assets/Fungus/VisualScripting/Sequence.cs index 8b41c058..8e9e7660 100644 --- a/Assets/Fungus/VisualScripting/Sequence.cs +++ b/Assets/Fungus/VisualScripting/Sequence.cs @@ -110,6 +110,7 @@ namespace Fungus public void Finish() { activeCommand = null; + sequenceController.activeSequence = null; // No more commands to run in current sequence #if UNITY_EDITOR diff --git a/Assets/Fungus/VisualScripting/SequenceController.cs b/Assets/Fungus/VisualScripting/SequenceController.cs index 25656064..9cb06253 100644 --- a/Assets/Fungus/VisualScripting/SequenceController.cs +++ b/Assets/Fungus/VisualScripting/SequenceController.cs @@ -2,6 +2,7 @@ using UnityEditor; #endif using UnityEngine; +using System; using System.Collections; using Fungus; @@ -9,11 +10,24 @@ public class SequenceController : MonoBehaviour { public float stepTime; + public Sequence startSequence; + + [System.NonSerialized] public Sequence activeSequence; + public void Execute() + { + if (startSequence == null) + { + return; + } + + ExecuteSequence(startSequence); + } + public void ExecuteSequence(Sequence sequence) { - if (activeSequence == null) + if (sequence == null) { return; }