Browse Source

Highlight command in inspector when clicked in editor

master
chrisgregan 11 years ago
parent
commit
0432b3cb8c
  1. 5
      Assets/Fungus/Editor/FungusCommandEditor.cs
  2. 29
      Assets/Fungus/Editor/FungusEditorWindow.cs
  3. 5
      Assets/Fungus/VisualScripting/Sequence.cs

5
Assets/Fungus/Editor/FungusCommandEditor.cs

@ -8,6 +8,8 @@ using Fungus;
public class FungusCommandEditor : Editor public class FungusCommandEditor : Editor
{ {
public static FungusCommand selectedCommand;
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
Rect rect = EditorGUILayout.BeginVertical(); Rect rect = EditorGUILayout.BeginVertical();
@ -24,7 +26,8 @@ public class FungusCommandEditor : Editor
EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style); EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style);
} }
if (t.IsExecuting()) if (t.IsExecuting() ||
t == selectedCommand)
{ {
EditorGUI.DrawRect(rect, new Color(1f, 1f, 0f, 0.25f)); EditorGUI.DrawRect(rect, new Color(1f, 1f, 0f, 0.25f));
} }

29
Assets/Fungus/Editor/FungusEditorWindow.cs

@ -111,9 +111,29 @@ public class FungusEditorWindow : EditorWindow
} }
} }
if (FungusCommandEditor.selectedCommand != null)
{
if (Selection.activeGameObject == null)
{
FungusCommandEditor.selectedCommand = null;
}
else
{
FungusCommand command = Selection.activeGameObject.GetComponent<FungusCommand>();
if (command == null)
{
FungusCommandEditor.selectedCommand = null;
}
else if (command.gameObject != FungusCommandEditor.selectedCommand.gameObject)
{
FungusCommandEditor.selectedCommand = null;
}
}
}
Sequence sequence = windowSequenceMap[windowId]; Sequence sequence = windowSequenceMap[windowId];
GUIStyle style = new GUIStyle(GUI.skin.box); GUIStyle style = new GUIStyle(GUI.skin.button);
FungusCommand[] commands = sequence.gameObject.GetComponents<FungusCommand>(); FungusCommand[] commands = sequence.gameObject.GetComponents<FungusCommand>();
foreach (FungusCommand command in commands) foreach (FungusCommand command in commands)
@ -134,7 +154,12 @@ public class FungusEditorWindow : EditorWindow
GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.white;
} }
GUILayout.Label(commandName, style, GUILayout.ExpandWidth(true)); if (GUILayout.Button(commandName, style, GUILayout.ExpandWidth(true)))
{
// Highlight the command in inspector
FungusCommandEditor.selectedCommand = command;
EditorUtility.SetDirty( command );
}
} }
GUI.DragWindow(); GUI.DragWindow();

5
Assets/Fungus/VisualScripting/Sequence.cs

@ -2,6 +2,7 @@
using UnityEditor; using UnityEditor;
#endif #endif
using UnityEngine; using UnityEngine;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -15,10 +16,10 @@ namespace Fungus
[HideInInspector] [HideInInspector]
public Rect nodeRect = new Rect(10, 10, 100, 100); public Rect nodeRect = new Rect(10, 10, 100, 100);
[HideInInspector] [System.NonSerialized]
public SequenceController sequenceController; public SequenceController sequenceController;
[HideInInspector] [System.NonSerialized]
public FungusCommand activeCommand; public FungusCommand activeCommand;
public virtual void Start() public virtual void Start()

Loading…
Cancel
Save