From 7aed9a01ffdaf6739774b871e65d921f46508518 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 18 Sep 2014 11:05:45 +0100 Subject: [PATCH] Refactored FungusScript advanced settings --- .../FungusScript/Editor/CommandEditor.cs | 2 +- .../FungusScript/Editor/CommandListAdaptor.cs | 2 +- .../FungusScript/Editor/FungusScriptEditor.cs | 18 ++---- .../FungusScript/Scripts/FungusScript.cs | 62 ++++++++++++------- .../Fungus/FungusScript/Scripts/Sequence.cs | 4 +- 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/Assets/Fungus/FungusScript/Editor/CommandEditor.cs b/Assets/Fungus/FungusScript/Editor/CommandEditor.cs index 42caeefb..d5e735e4 100644 --- a/Assets/Fungus/FungusScript/Editor/CommandEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/CommandEditor.cs @@ -56,7 +56,7 @@ namespace Fungus GUIStyle commandStyle = new GUIStyle(EditorStyles.miniButton); if (t.enabled) { - if (fungusScript.colorCommands) + if (fungusScript.settings.colorCommands) { GUI.backgroundColor = t.GetButtonColor(); } diff --git a/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs b/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs index b2069df5..9adb7200 100644 --- a/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs @@ -208,7 +208,7 @@ namespace Fungus } Color buttonBackgroundColor = Color.white; - if (fungusScript.colorCommands) + if (fungusScript.settings.colorCommands) { buttonBackgroundColor = command.GetButtonColor(); } diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs index a06a6199..653aafcb 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs @@ -10,20 +10,16 @@ namespace Fungus [CustomEditor (typeof(FungusScript))] public class FungusScriptEditor : Editor { - SerializedProperty stepTimeProp; SerializedProperty startSequenceProp; SerializedProperty executeOnStartProp; - SerializedProperty colorCommandsProp; - SerializedProperty showSequenceObjectsProp; + SerializedProperty settingsProp; SerializedProperty variablesProp; void OnEnable() { - stepTimeProp = serializedObject.FindProperty("stepTime"); startSequenceProp = serializedObject.FindProperty("startSequence"); executeOnStartProp = serializedObject.FindProperty("executeOnStart"); - colorCommandsProp = serializedObject.FindProperty("colorCommands"); - showSequenceObjectsProp = serializedObject.FindProperty("showSequenceObjects"); + settingsProp = serializedObject.FindProperty("settings"); variablesProp = serializedObject.FindProperty("variables"); } @@ -52,10 +48,8 @@ namespace Fungus } } - EditorGUILayout.PropertyField(stepTimeProp, new GUIContent("Step Time", "Minimum time to execute each step")); - SequenceEditor.SequenceField(startSequenceProp, - new GUIContent("Start Sequence", "Sequence to be executed when controller starts."), + new GUIContent("Start Sequence", "First sequence to execute when the Fungus Script executes"), new GUIContent(""), t); @@ -66,11 +60,9 @@ namespace Fungus EditorGUILayout.LabelField(new GUIContent("Error: Please select a Start Sequence"), style); } - EditorGUILayout.PropertyField(executeOnStartProp, new GUIContent("Execute On Start", "Execute this Fungus Script when the scene starts.")); - - EditorGUILayout.PropertyField(colorCommandsProp, new GUIContent("Color Commands", "Display commands using colors in editor window.")); + EditorGUILayout.PropertyField(executeOnStartProp, new GUIContent("Execute On Start", "Execute this Fungus Script when the scene starts playing")); - EditorGUILayout.PropertyField(showSequenceObjectsProp, new GUIContent("Show Sequence Objects", "Display the child Sequence game objects in the hierarchy view.")); + EditorGUILayout.PropertyField(settingsProp, new GUIContent("Settings", "Configution options for the Fungus Script"), true); EditorGUILayout.Separator(); diff --git a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs index f8f024f3..ef1f998d 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs @@ -43,46 +43,66 @@ namespace Fungus [HideInInspector] public float commandViewWidth = 350; - /** - * Execution speed when running the script in the editor. Pauses on each command to help visualise execution order. - */ - public float stepTime; - - /** - * First sequence to execute when the Fungus Script executes. - */ - public Sequence startSequence; - /** * Currently selected sequence in the Fungus Script editor. */ + [HideInInspector] public Sequence selectedSequence; - + /** * Currently selected command in the Fungus Script editor. */ + [HideInInspector] public Command selectedCommand; /** - * Execute this Fungus Script when the scene starts. + * The list of variables that can be accessed by the Fungus Script. */ - public bool executeOnStart = true; + [HideInInspector] + public List variables = new List(); /** - * Use command color when displaying command list in Fungus Editor window. + * First sequence to execute when the Fungus Script executes. */ - public bool colorCommands = true; + [Tooltip("First sequence to execute when the Fungus Script executes")] + public Sequence startSequence; /** - * Show the sequence game objects in the Hierarchy view. - * This can be useful if you want to inspect the child gameobjects and components that make up the Fungus Script. + * Execute this Fungus Script when the scene starts. */ - public bool showSequenceObjects = false; + [Tooltip("Execute this Fungus Script when the scene starts playing")] + public bool executeOnStart = true; + + [System.Serializable] + public class Settings + { + /** + * Minimum time for each command to execute when playing the scene in the editor. + * Slowing down the program flow makes it easier to visualise execution order. + */ + [Range(0f, 5f)] + [Tooltip("Minimum time for each command to execute when playing the scene in the editor")] + public float minCommandDuration = 0.25f; + + /** + * Use command color when displaying the command list in the Fungus Editor window. + */ + [Tooltip("Use command color when displaying the command list in the Fungus Editor window")] + public bool colorCommands = true; + + /** + * Hides the child sequence game objects in the Hierarchy view. + * Deselect to inspect the child gameobjects and components that make up the Fungus Script. + */ + [Tooltip("Hides the child sequence game objects in the Hierarchy view")] + public bool hideSequenceObjects = true; + } /** - * The list of variables that can be accessed by the Fungus Script. + * Advanced configuration options for the Fungus Script. */ - public List variables = new List(); + [Tooltip("Advanced configuration options for the Fungus Script")] + public Settings settings; void Start() { @@ -360,7 +380,7 @@ namespace Fungus Sequence[] sequences = GetComponentsInChildren(); foreach (Sequence sequence in sequences) { - sequence.gameObject.hideFlags = showSequenceObjects ? HideFlags.None : HideFlags.HideInHierarchy; + sequence.gameObject.hideFlags = settings.hideSequenceObjects ? HideFlags.HideInHierarchy : HideFlags.None; } } } diff --git a/Assets/Fungus/FungusScript/Scripts/Sequence.cs b/Assets/Fungus/FungusScript/Scripts/Sequence.cs index 44a4cfa6..b40ce9d4 100644 --- a/Assets/Fungus/FungusScript/Scripts/Sequence.cs +++ b/Assets/Fungus/FungusScript/Scripts/Sequence.cs @@ -94,14 +94,14 @@ namespace Fungus { FungusScript fungusScript = GetFungusScript(); - if (fungusScript.stepTime == 0f) + if (fungusScript.settings.minCommandDuration == 0f) { activeCommand = nextCommand; nextCommand.Execute(); } else { - StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.stepTime)); + StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.settings.minCommandDuration)); } }