Browse Source

FungusScriptEditor handles sequence display

master
chrisgregan 11 years ago
parent
commit
4dce521533
  1. 15
      Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs
  2. 72
      Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs
  3. 4
      Assets/Fungus/Editor/FungusScript/SequenceEditor.cs
  4. 2
      Assets/Fungus/VisualScripting/FungusScript.cs
  5. BIN
      Assets/Shuttle/ShuttleGame.unity

15
Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs

@ -62,6 +62,12 @@ namespace Fungus.Script
return; return;
} }
if (Event.current.button == 0 &&
Event.current.type == EventType.MouseDown)
{
fungusScript.selectedSequence = null;
}
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
Rect scrollViewRect = new Rect(); Rect scrollViewRect = new Rect();
@ -98,7 +104,7 @@ namespace Fungus.Script
float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x; float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x;
float windowWidth = Mathf.Max (titleWidth + 10, 100); float windowWidth = Mathf.Max (titleWidth + 10, 100);
if (Selection.activeGameObject == sequence.gameObject) if (fungusScript.selectedSequence == sequence)
{ {
Rect outlineRect = sequence.nodeRect; Rect outlineRect = sequence.nodeRect;
outlineRect.width += 10; outlineRect.width += 10;
@ -168,16 +174,17 @@ namespace Fungus.Script
void DrawWindow(int windowId) void DrawWindow(int windowId)
{ {
// Select game object when node is clicked // Select sequence when node is clicked
if (Event.current.button == 0 && if (Event.current.button == 0 &&
Event.current.type == EventType.MouseUp) Event.current.type == EventType.MouseDown)
{ {
if (windowId < windowSequenceMap.Count) if (windowId < windowSequenceMap.Count)
{ {
Sequence s = windowSequenceMap[windowId]; Sequence s = windowSequenceMap[windowId];
if (s != null) if (s != null)
{ {
Selection.activeGameObject = s.gameObject; FungusScript fungusScript = s.GetFungusScript();
fungusScript.selectedSequence = s;
} }
} }
} }

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

@ -48,7 +48,6 @@ namespace Fungus.Script
s.nodeRect.x = fungusEditorWindow.scrollPos.x; s.nodeRect.x = fungusEditorWindow.scrollPos.x;
s.nodeRect.y = fungusEditorWindow.scrollPos.y; s.nodeRect.y = fungusEditorWindow.scrollPos.y;
Undo.RegisterCreatedObjectUndo(go, "Sequence"); Undo.RegisterCreatedObjectUndo(go, "Sequence");
Selection.activeGameObject = go;
} }
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
@ -60,9 +59,6 @@ namespace Fungus.Script
GUIContent startSequenceLabel = new GUIContent("Start Sequence", "Sequence to be executed when controller starts."); GUIContent startSequenceLabel = new GUIContent("Start Sequence", "Sequence to be executed when controller starts.");
t.startSequence = SequenceEditor.SequenceField(startSequenceLabel, t, t.startSequence); t.startSequence = SequenceEditor.SequenceField(startSequenceLabel, t, t.startSequence);
GUIContent startAutomaticallyLabel = new GUIContent("Start Automatically", "Start this Fungus Script when the scene starts.");
t.startAutomatically = EditorGUILayout.Toggle(startAutomaticallyLabel, t.startAutomatically);
if (t.startSequence == null) if (t.startSequence == null)
{ {
GUIStyle style = new GUIStyle(GUI.skin.label); GUIStyle style = new GUIStyle(GUI.skin.label);
@ -70,9 +66,77 @@ namespace Fungus.Script
EditorGUILayout.LabelField(new GUIContent("Error: Please select a Start Sequence"), style); EditorGUILayout.LabelField(new GUIContent("Error: Please select a Start Sequence"), style);
} }
GUIContent startAutomaticallyLabel = new GUIContent("Start Automatically", "Start this Fungus Script when the scene starts.");
t.startAutomatically = EditorGUILayout.Toggle(startAutomaticallyLabel, t.startAutomatically);
if (t.selectedSequence != null)
{
DrawSequenceGUI(t.selectedSequence);
}
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
public void DrawSequenceGUI(Sequence sequence)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.Separator();
GUILayout.Box("Sequence", GUILayout.ExpandWidth(true));
EditorGUILayout.Separator();
string sequenceName = EditorGUILayout.TextField(new GUIContent("Name", "Name of sequence displayed in editor window"), sequence.name);
string sequenceDescription = EditorGUILayout.TextField(new GUIContent("Description", "Sequence description displayed in editor window"), sequence.description);
EditorGUILayout.Separator();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sequence, "Set Sequence");
sequence.name = sequenceName;
sequence.description = sequenceDescription;
}
/*
if (Application.isPlaying)
{
foreach (FungusCommand command in commands)
{
if (command == FungusCommandEditor.selectedCommand)
{
activeCommand = command;
Debug.Log("Found it");
}
}
}
*/
EditorGUILayout.PrefixLabel("Commands");
FungusCommand[] commands = sequence.GetComponents<FungusCommand>();
foreach (FungusCommand command in commands)
{
/*
bool showCommandInspector = false;
if (command == activeCommand ||
command.IsExecuting())
{
showCommandInspector = true;
}
*/
if (GUILayout.Button(command.GetCommandTitle()))
{
command.expanded = !command.expanded;
}
if (command.expanded)
{
Editor commandEditor = Editor.CreateEditor(command);
commandEditor.OnInspectorGUI();
}
}
}
public void DrawVariablesGUI() public void DrawVariablesGUI()
{ {
serializedObject.Update(); serializedObject.Update();

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

@ -10,7 +10,7 @@ namespace Fungus.Script
[CustomEditor (typeof(Sequence))] [CustomEditor (typeof(Sequence))]
public class SequenceEditor : Editor public class SequenceEditor : Editor
{ {
FungusCommand activeCommand; // FungusCommand activeCommand;
static public Sequence SequenceField(GUIContent label, FungusScript fungusScript, Sequence sequence) static public Sequence SequenceField(GUIContent label, FungusScript fungusScript, Sequence sequence)
{ {
@ -88,12 +88,14 @@ namespace Fungus.Script
foreach (FungusCommand command in commands) foreach (FungusCommand command in commands)
{ {
/*
bool showCommandInspector = false; bool showCommandInspector = false;
if (command == activeCommand || if (command == activeCommand ||
command.IsExecuting()) command.IsExecuting())
{ {
showCommandInspector = true; showCommandInspector = true;
} }
*/
if (GUILayout.Button(command.GetCommandTitle())) if (GUILayout.Button(command.GetCommandTitle()))
{ {

2
Assets/Fungus/VisualScripting/FungusScript.cs

@ -18,6 +18,8 @@ namespace Fungus.Script
[System.NonSerialized] [System.NonSerialized]
public Sequence executingSequence; public Sequence executingSequence;
public Sequence selectedSequence;
public bool startAutomatically = false; public bool startAutomatically = false;
public List<FungusVariable> variables = new List<FungusVariable>(); public List<FungusVariable> variables = new List<FungusVariable>();

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save