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 72fdd2b5..d9eccb36 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ