diff --git a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs index 283f43e0..c03f7e7f 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs @@ -9,9 +9,14 @@ namespace Fungus.Script [CustomEditor (typeof(FungusCommand), true)] public class FungusCommandEditor : Editor { - public static FungusCommand selectedCommand; + void OnEnable() + { + FungusCommand t = target as FungusCommand; + t.hideFlags = HideFlags.HideInInspector; + } + public override void OnInspectorGUI() { Rect rect = EditorGUILayout.BeginVertical(); diff --git a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs index de03c7d2..2654bb1d 100755 --- a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs @@ -98,7 +98,7 @@ namespace Fungus.Script float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x; float windowWidth = Mathf.Max (titleWidth + 10, 100); - sequence.nodeRect = GUILayout.Window(i, sequence.nodeRect, DrawWindow, sequence.name, GUILayout.Width(windowWidth), GUILayout.Height(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); + sequence.nodeRect = GUILayout.Window(i, sequence.nodeRect, DrawWindow, sequence.name, GUILayout.Width(windowWidth), GUILayout.Height(40), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); windowSequenceMap.Add(sequence); } @@ -194,12 +194,20 @@ namespace Fungus.Script Sequence sequence = windowSequenceMap[windowId]; + string description = GUILayout.TextArea(sequence.description, GUILayout.ExpandWidth(true)); + if (description != sequence.description) + { + Undo.RecordObject(sequence, "Set Description"); + sequence.description = description; + } + + /* GUIStyle style = new GUIStyle(GUI.skin.button); FungusCommand[] commands = sequence.gameObject.GetComponents(); foreach (FungusCommand command in commands) { - string commandName = command.GetCommandName(); + string commandName = command.GetCommandTitle(); if (command.errorMessage.Length > 0) { @@ -233,8 +241,10 @@ namespace Fungus.Script // Add an invisible element if there are no commands to avoid window width/height collapsing if (commands.Length == 0) { - GUILayout.Space(10); } + */ + + GUILayout.Space(10); GUI.DragWindow(); } diff --git a/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs b/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs index ba2918b9..43dfc3be 100644 --- a/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SequenceEditor.cs @@ -10,6 +10,8 @@ namespace Fungus.Script [CustomEditor (typeof(Sequence))] public class SequenceEditor : Editor { + FungusCommand activeCommand; + static public Sequence SequenceField(GUIContent label, FungusScript fungusScript, Sequence sequence) { if (fungusScript == null) @@ -47,6 +49,67 @@ namespace Fungus.Script return result; } + + public override bool RequiresConstantRepaint() + { + return true; + } + + /* + public void OnInspectorUpdate() + { + Repaint(); + } + */ + + public override void OnInspectorGUI() + { + Sequence t = target as Sequence; + + FungusCommand[] commands = t.GetComponents(); + + /* + if (Application.isPlaying) + { + foreach (FungusCommand command in commands) + { + if (command == FungusCommandEditor.selectedCommand) + { + activeCommand = command; + Debug.Log("Found it"); + } + } + } + */ + + foreach (FungusCommand command in commands) + { + bool showCommandInspector = false; + if (command == activeCommand || + command.IsExecuting()) + { + showCommandInspector = true; + } + + if (GUILayout.Button(command.GetCommandTitle())) + { + if (activeCommand == command) + { + activeCommand = null; + } + else + { + activeCommand = command; + } + } + + if (showCommandInspector) + { + Editor commandEditor = Editor.CreateEditor(command); + commandEditor.OnInspectorGUI(); + } + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Call.cs b/Assets/Fungus/VisualScripting/Call.cs index 96a08dd6..04e240fa 100644 --- a/Assets/Fungus/VisualScripting/Call.cs +++ b/Assets/Fungus/VisualScripting/Call.cs @@ -185,7 +185,7 @@ namespace Fungus.Script } } - public override string GetCommandName() + public override string GetCommandTitle() { if (callCondition == CallCondition.CallAlways) { diff --git a/Assets/Fungus/VisualScripting/FungusCommand.cs b/Assets/Fungus/VisualScripting/FungusCommand.cs index 77fe88f2..347687f5 100644 --- a/Assets/Fungus/VisualScripting/FungusCommand.cs +++ b/Assets/Fungus/VisualScripting/FungusCommand.cs @@ -85,7 +85,7 @@ namespace Fungus.Script public virtual void GetConnectedSequences(ref List connectedSequences) {} - public virtual string GetCommandName() + public virtual string GetCommandTitle() { return GetType().Name; } diff --git a/Assets/Fungus/VisualScripting/Sequence.cs b/Assets/Fungus/VisualScripting/Sequence.cs index 1a5694d6..8e695fb7 100644 --- a/Assets/Fungus/VisualScripting/Sequence.cs +++ b/Assets/Fungus/VisualScripting/Sequence.cs @@ -14,6 +14,9 @@ namespace Fungus.Script [HideInInspector] public Rect nodeRect = new Rect(10, 10, 100, 100); + [HideInInspector] + public string description = ""; + [System.NonSerialized] public FungusScript fungusScript; diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 87c4562d..1f55a733 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ