Browse Source

Refactored FungusScript advanced settings

master
chrisgregan 10 years ago
parent
commit
7aed9a01ff
  1. 2
      Assets/Fungus/FungusScript/Editor/CommandEditor.cs
  2. 2
      Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs
  3. 18
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  4. 62
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs
  5. 4
      Assets/Fungus/FungusScript/Scripts/Sequence.cs

2
Assets/Fungus/FungusScript/Editor/CommandEditor.cs

@ -56,7 +56,7 @@ namespace Fungus
GUIStyle commandStyle = new GUIStyle(EditorStyles.miniButton); GUIStyle commandStyle = new GUIStyle(EditorStyles.miniButton);
if (t.enabled) if (t.enabled)
{ {
if (fungusScript.colorCommands) if (fungusScript.settings.colorCommands)
{ {
GUI.backgroundColor = t.GetButtonColor(); GUI.backgroundColor = t.GetButtonColor();
} }

2
Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs

@ -208,7 +208,7 @@ namespace Fungus
} }
Color buttonBackgroundColor = Color.white; Color buttonBackgroundColor = Color.white;
if (fungusScript.colorCommands) if (fungusScript.settings.colorCommands)
{ {
buttonBackgroundColor = command.GetButtonColor(); buttonBackgroundColor = command.GetButtonColor();
} }

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

@ -10,20 +10,16 @@ namespace Fungus
[CustomEditor (typeof(FungusScript))] [CustomEditor (typeof(FungusScript))]
public class FungusScriptEditor : Editor public class FungusScriptEditor : Editor
{ {
SerializedProperty stepTimeProp;
SerializedProperty startSequenceProp; SerializedProperty startSequenceProp;
SerializedProperty executeOnStartProp; SerializedProperty executeOnStartProp;
SerializedProperty colorCommandsProp; SerializedProperty settingsProp;
SerializedProperty showSequenceObjectsProp;
SerializedProperty variablesProp; SerializedProperty variablesProp;
void OnEnable() void OnEnable()
{ {
stepTimeProp = serializedObject.FindProperty("stepTime");
startSequenceProp = serializedObject.FindProperty("startSequence"); startSequenceProp = serializedObject.FindProperty("startSequence");
executeOnStartProp = serializedObject.FindProperty("executeOnStart"); executeOnStartProp = serializedObject.FindProperty("executeOnStart");
colorCommandsProp = serializedObject.FindProperty("colorCommands"); settingsProp = serializedObject.FindProperty("settings");
showSequenceObjectsProp = serializedObject.FindProperty("showSequenceObjects");
variablesProp = serializedObject.FindProperty("variables"); 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, 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("<None>"), new GUIContent("<None>"),
t); t);
@ -66,11 +60,9 @@ namespace Fungus
EditorGUILayout.LabelField(new GUIContent("Error: Please select a Start Sequence"), style); 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(executeOnStartProp, new GUIContent("Execute On Start", "Execute this Fungus Script when the scene starts playing"));
EditorGUILayout.PropertyField(colorCommandsProp, new GUIContent("Color Commands", "Display commands using colors in editor window."));
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(); EditorGUILayout.Separator();

62
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -43,46 +43,66 @@ namespace Fungus
[HideInInspector] [HideInInspector]
public float commandViewWidth = 350; 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. * Currently selected sequence in the Fungus Script editor.
*/ */
[HideInInspector]
public Sequence selectedSequence; public Sequence selectedSequence;
/** /**
* Currently selected command in the Fungus Script editor. * Currently selected command in the Fungus Script editor.
*/ */
[HideInInspector]
public Command selectedCommand; 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<Variable> variables = new List<Variable>();
/** /**
* 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. * Execute this Fungus Script when the scene starts.
* This can be useful if you want to inspect the child gameobjects and components that make up the Fungus Script.
*/ */
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<Variable> variables = new List<Variable>(); [Tooltip("Advanced configuration options for the Fungus Script")]
public Settings settings;
void Start() void Start()
{ {
@ -360,7 +380,7 @@ namespace Fungus
Sequence[] sequences = GetComponentsInChildren<Sequence>(); Sequence[] sequences = GetComponentsInChildren<Sequence>();
foreach (Sequence sequence in sequences) foreach (Sequence sequence in sequences)
{ {
sequence.gameObject.hideFlags = showSequenceObjects ? HideFlags.None : HideFlags.HideInHierarchy; sequence.gameObject.hideFlags = settings.hideSequenceObjects ? HideFlags.HideInHierarchy : HideFlags.None;
} }
} }
} }

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

@ -94,14 +94,14 @@ namespace Fungus
{ {
FungusScript fungusScript = GetFungusScript(); FungusScript fungusScript = GetFungusScript();
if (fungusScript.stepTime == 0f) if (fungusScript.settings.minCommandDuration == 0f)
{ {
activeCommand = nextCommand; activeCommand = nextCommand;
nextCommand.Execute(); nextCommand.Execute();
} }
else else
{ {
StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.stepTime)); StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.settings.minCommandDuration));
} }
} }

Loading…
Cancel
Save