From 4dce521533ab4ccb9aacefc0d19d52c92314613c Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 13 Aug 2014 11:37:54 +0100 Subject: [PATCH] FungusScriptEditor handles sequence display --- .../Editor/FungusScript/FungusEditorWindow.cs | 15 +++- .../Editor/FungusScript/FungusScriptEditor.cs | 78 ++++++++++++++++-- .../Editor/FungusScript/SequenceEditor.cs | 4 +- Assets/Fungus/VisualScripting/FungusScript.cs | 4 +- Assets/Shuttle/ShuttleGame.unity | Bin 81492 -> 81956 bytes 5 files changed, 88 insertions(+), 13 deletions(-) diff --git a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs index 00d16641..960b40df 100755 --- a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs @@ -62,6 +62,12 @@ namespace Fungus.Script return; } + if (Event.current.button == 0 && + Event.current.type == EventType.MouseDown) + { + fungusScript.selectedSequence = null; + } + Sequence[] sequences = fungusScript.GetComponentsInChildren(); Rect scrollViewRect = new Rect(); @@ -98,7 +104,7 @@ namespace Fungus.Script float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x; float windowWidth = Mathf.Max (titleWidth + 10, 100); - if (Selection.activeGameObject == sequence.gameObject) + if (fungusScript.selectedSequence == sequence) { Rect outlineRect = sequence.nodeRect; outlineRect.width += 10; @@ -168,16 +174,17 @@ namespace Fungus.Script void DrawWindow(int windowId) { - // Select game object when node is clicked + // Select sequence when node is clicked if (Event.current.button == 0 && - Event.current.type == EventType.MouseUp) + Event.current.type == EventType.MouseDown) { if (windowId < windowSequenceMap.Count) { Sequence s = windowSequenceMap[windowId]; if (s != null) { - Selection.activeGameObject = s.gameObject; + FungusScript fungusScript = s.GetFungusScript(); + fungusScript.selectedSequence = s; } } } diff --git a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs index b888c972..062bd883 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs @@ -48,7 +48,6 @@ namespace Fungus.Script s.nodeRect.x = fungusEditorWindow.scrollPos.x; s.nodeRect.y = fungusEditorWindow.scrollPos.y; Undo.RegisterCreatedObjectUndo(go, "Sequence"); - Selection.activeGameObject = go; } GUILayout.FlexibleSpace(); @@ -59,20 +58,85 @@ namespace Fungus.Script GUIContent startSequenceLabel = new GUIContent("Start Sequence", "Sequence to be executed when controller starts."); 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) { GUIStyle style = new GUIStyle(GUI.skin.label); style.normal.textColor = new Color(1,0,0); 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(); } - + + 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(); + 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() { serializedObject.Update(); diff --git a/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs b/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs index 8e34d051..928de16a 100644 --- a/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs @@ -10,7 +10,7 @@ namespace Fungus.Script [CustomEditor (typeof(Sequence))] public class SequenceEditor : Editor { - FungusCommand activeCommand; + // FungusCommand activeCommand; static public Sequence SequenceField(GUIContent label, FungusScript fungusScript, Sequence sequence) { @@ -88,12 +88,14 @@ namespace Fungus.Script foreach (FungusCommand command in commands) { + /* bool showCommandInspector = false; if (command == activeCommand || command.IsExecuting()) { showCommandInspector = true; } + */ if (GUILayout.Button(command.GetCommandTitle())) { diff --git a/Assets/Fungus/VisualScripting/FungusScript.cs b/Assets/Fungus/VisualScripting/FungusScript.cs index 9f36cd52..2750e3a8 100644 --- a/Assets/Fungus/VisualScripting/FungusScript.cs +++ b/Assets/Fungus/VisualScripting/FungusScript.cs @@ -17,7 +17,9 @@ namespace Fungus.Script [System.NonSerialized] public Sequence executingSequence; - + + public Sequence selectedSequence; + public bool startAutomatically = false; public List variables = new List(); diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 72fdd2b50168bc3c21731ca729ac5f23db833999..d9eccb3610240f16c6e37655ac47451817642424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