Browse Source

Commands are now listed in inspector

master
chrisgregan 11 years ago
parent
commit
3703c53276
  1. 7
      Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs
  2. 16
      Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs
  3. 63
      Assets/Fungus/Editor/FungusScript/SequenceEditor.cs
  4. 2
      Assets/Fungus/VisualScripting/Call.cs
  5. 2
      Assets/Fungus/VisualScripting/FungusCommand.cs
  6. 3
      Assets/Fungus/VisualScripting/Sequence.cs
  7. BIN
      Assets/Shuttle/ShuttleGame.unity

7
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();

16
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<FungusCommand>();
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();
}

63
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<FungusCommand>();
/*
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();
}
}
}
}
}

2
Assets/Fungus/VisualScripting/Call.cs

@ -185,7 +185,7 @@ namespace Fungus.Script
}
}
public override string GetCommandName()
public override string GetCommandTitle()
{
if (callCondition == CallCondition.CallAlways)
{

2
Assets/Fungus/VisualScripting/FungusCommand.cs

@ -85,7 +85,7 @@ namespace Fungus.Script
public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences)
{}
public virtual string GetCommandName()
public virtual string GetCommandTitle()
{
return GetType().Name;
}

3
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;

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save