diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs index e4ef74be..50fe8f64 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs @@ -10,18 +10,16 @@ namespace Fungus [CustomEditor (typeof(FungusScript))] public class FungusScriptEditor : Editor { - protected SerializedProperty runSlowInEditorProp; - protected SerializedProperty runSlowDurationProp; protected SerializedProperty colorCommandsProp; protected SerializedProperty hideComponentsProp; + protected SerializedProperty runSlowDurationProp; protected SerializedProperty variablesProp; protected virtual void OnEnable() { - runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor"); - runSlowDurationProp = serializedObject.FindProperty("runSlowDuration"); colorCommandsProp = serializedObject.FindProperty("colorCommands"); hideComponentsProp = serializedObject.FindProperty("hideComponents"); + runSlowDurationProp = serializedObject.FindProperty("runSlowDuration"); variablesProp = serializedObject.FindProperty("variables"); } @@ -33,10 +31,9 @@ namespace Fungus fungusScript.UpdateHideFlags(); - EditorGUILayout.PropertyField(runSlowInEditorProp); - EditorGUILayout.PropertyField(runSlowDurationProp); EditorGUILayout.PropertyField(colorCommandsProp); EditorGUILayout.PropertyField(hideComponentsProp); + EditorGUILayout.PropertyField(runSlowDurationProp); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); diff --git a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs index a6dd9a2c..c668a146 100644 --- a/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/SequenceEditor.cs @@ -31,6 +31,9 @@ namespace Fungus Sequence sequence = target as Sequence; + SerializedProperty runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor"); + EditorGUILayout.PropertyField(runSlowInEditorProp); + DrawEventHandlerGUI(fungusScript); UpdateIndentLevels(sequence); diff --git a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs index b623e305..da3b2a8b 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs @@ -59,12 +59,6 @@ namespace Fungus [HideInInspector] public List variables = new List(); - /** - * Slow down execution when playing in the editor to make it easier to visualise program flow. - */ - [Tooltip("Slow down execution in the editor to make it easier to visualise program flow")] - public bool runSlowInEditor = true; - /** * Minimum time for each command to execute when runSlowInEditor is enabled. */ diff --git a/Assets/Fungus/FungusScript/Scripts/Sequence.cs b/Assets/Fungus/FungusScript/Scripts/Sequence.cs index edfb7c2b..15478681 100644 --- a/Assets/Fungus/FungusScript/Scripts/Sequence.cs +++ b/Assets/Fungus/FungusScript/Scripts/Sequence.cs @@ -12,6 +12,9 @@ namespace Fungus { public string sequenceName = "New Sequence"; + [Tooltip("Slow down execution in the editor to make it easier to visualise program flow")] + public bool runSlowInEditor = true; + public EventHandler eventHandler; [HideInInspector] @@ -96,7 +99,7 @@ namespace Fungus } else if (executeNext) { - if (command.enabled) + if (command.enabled && command.GetType() != typeof(Comment)) { nextCommand = command; break; @@ -112,14 +115,17 @@ namespace Fungus { FungusScript fungusScript = GetFungusScript(); - if (!fungusScript.runSlowInEditor) - { - activeCommand = nextCommand; - nextCommand.Execute(); - } - else + if (fungusScript.gameObject.activeInHierarchy) { - StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.runSlowDuration)); + if (!runSlowInEditor) + { + activeCommand = nextCommand; + nextCommand.Execute(); + } + else + { + StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.runSlowDuration)); + } } }