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. 50
      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);
if (t.enabled)
{
if (fungusScript.colorCommands)
if (fungusScript.settings.colorCommands)
{
GUI.backgroundColor = t.GetButtonColor();
}

2
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();
}

18
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("<None>"),
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();

50
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -44,45 +44,65 @@ namespace Fungus
public float commandViewWidth = 350;
/**
* Execution speed when running the script in the editor. Pauses on each command to help visualise execution order.
* Currently selected sequence in the Fungus Script editor.
*/
public float stepTime;
[HideInInspector]
public Sequence selectedSequence;
/**
* First sequence to execute when the Fungus Script executes.
* Currently selected command in the Fungus Script editor.
*/
public Sequence startSequence;
[HideInInspector]
public Command selectedCommand;
/**
* Currently selected sequence in the Fungus Script editor.
* The list of variables that can be accessed by the Fungus Script.
*/
public Sequence selectedSequence;
[HideInInspector]
public List<Variable> variables = new List<Variable>();
/**
* Currently selected command in the Fungus Script editor.
* First sequence to execute when the Fungus Script executes.
*/
public Command selectedCommand;
[Tooltip("First sequence to execute when the Fungus Script executes")]
public Sequence startSequence;
/**
* Execute this Fungus Script when the scene starts.
*/
[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 command list in Fungus Editor window.
* 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;
/**
* 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.
* Hides the child sequence game objects in the Hierarchy view.
* Deselect to inspect the child gameobjects and components that make up the Fungus Script.
*/
public bool showSequenceObjects = false;
[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()
{
@ -360,7 +380,7 @@ namespace Fungus
Sequence[] sequences = GetComponentsInChildren<Sequence>();
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();
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));
}
}

Loading…
Cancel
Save