Browse Source

Moved Run Slow in Editor option to Sequence

Comments are skipped over immediately (no waiting)
master
chrisgregan 10 years ago
parent
commit
e249049858
  1. 9
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  2. 3
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
  3. 6
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs
  4. 22
      Assets/Fungus/FungusScript/Scripts/Sequence.cs

9
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -10,18 +10,16 @@ namespace Fungus
[CustomEditor (typeof(FungusScript))] [CustomEditor (typeof(FungusScript))]
public class FungusScriptEditor : Editor public class FungusScriptEditor : Editor
{ {
protected SerializedProperty runSlowInEditorProp;
protected SerializedProperty runSlowDurationProp;
protected SerializedProperty colorCommandsProp; protected SerializedProperty colorCommandsProp;
protected SerializedProperty hideComponentsProp; protected SerializedProperty hideComponentsProp;
protected SerializedProperty runSlowDurationProp;
protected SerializedProperty variablesProp; protected SerializedProperty variablesProp;
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor");
runSlowDurationProp = serializedObject.FindProperty("runSlowDuration");
colorCommandsProp = serializedObject.FindProperty("colorCommands"); colorCommandsProp = serializedObject.FindProperty("colorCommands");
hideComponentsProp = serializedObject.FindProperty("hideComponents"); hideComponentsProp = serializedObject.FindProperty("hideComponents");
runSlowDurationProp = serializedObject.FindProperty("runSlowDuration");
variablesProp = serializedObject.FindProperty("variables"); variablesProp = serializedObject.FindProperty("variables");
} }
@ -33,10 +31,9 @@ namespace Fungus
fungusScript.UpdateHideFlags(); fungusScript.UpdateHideFlags();
EditorGUILayout.PropertyField(runSlowInEditorProp);
EditorGUILayout.PropertyField(runSlowDurationProp);
EditorGUILayout.PropertyField(colorCommandsProp); EditorGUILayout.PropertyField(colorCommandsProp);
EditorGUILayout.PropertyField(hideComponentsProp); EditorGUILayout.PropertyField(hideComponentsProp);
EditorGUILayout.PropertyField(runSlowDurationProp);
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();

3
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -31,6 +31,9 @@ namespace Fungus
Sequence sequence = target as Sequence; Sequence sequence = target as Sequence;
SerializedProperty runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor");
EditorGUILayout.PropertyField(runSlowInEditorProp);
DrawEventHandlerGUI(fungusScript); DrawEventHandlerGUI(fungusScript);
UpdateIndentLevels(sequence); UpdateIndentLevels(sequence);

6
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -59,12 +59,6 @@ namespace Fungus
[HideInInspector] [HideInInspector]
public List<Variable> variables = new List<Variable>(); public List<Variable> variables = new List<Variable>();
/**
* 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. * Minimum time for each command to execute when runSlowInEditor is enabled.
*/ */

22
Assets/Fungus/FungusScript/Scripts/Sequence.cs

@ -12,6 +12,9 @@ namespace Fungus
{ {
public string sequenceName = "New Sequence"; 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; public EventHandler eventHandler;
[HideInInspector] [HideInInspector]
@ -96,7 +99,7 @@ namespace Fungus
} }
else if (executeNext) else if (executeNext)
{ {
if (command.enabled) if (command.enabled && command.GetType() != typeof(Comment))
{ {
nextCommand = command; nextCommand = command;
break; break;
@ -112,14 +115,17 @@ namespace Fungus
{ {
FungusScript fungusScript = GetFungusScript(); FungusScript fungusScript = GetFungusScript();
if (!fungusScript.runSlowInEditor) if (fungusScript.gameObject.activeInHierarchy)
{
activeCommand = nextCommand;
nextCommand.Execute();
}
else
{ {
StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.runSlowDuration)); if (!runSlowInEditor)
{
activeCommand = nextCommand;
nextCommand.Execute();
}
else
{
StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.runSlowDuration));
}
} }
} }

Loading…
Cancel
Save