From 3703c53276bf876673bb7e169e682d05a1762cc3 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Tue, 12 Aug 2014 10:24:28 +0100 Subject: [PATCH] Commands are now listed in inspector --- .../FungusScript/FungusCommandEditor.cs | 7 +- .../Editor/FungusScript/FungusEditorWindow.cs | 16 ++++- .../Editor/FungusScript/SequenceEditor.cs | 63 ++++++++++++++++++ Assets/Fungus/VisualScripting/Call.cs | 2 +- .../Fungus/VisualScripting/FungusCommand.cs | 2 +- Assets/Fungus/VisualScripting/Sequence.cs | 3 + Assets/Shuttle/ShuttleGame.unity | Bin 80900 -> 81084 bytes 7 files changed, 87 insertions(+), 6 deletions(-) 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 87c4562d898b9829525e09513a861587a7520731..1f55a733a7aeb1b6bbcfefa5afb246c5138bec15 100644 GIT binary patch delta 2291 zcmZA2ZA@EL7zgm@lmbQ z8=Jb3UFIFS#G559WZ4G@8ouB{qKPb7%s$LyCi^fqROY8;j!|A_{omeu;It$s?fKp3 zIp;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