|
|
@ -3,284 +3,288 @@ using UnityEditor; |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Fungus; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class FungusEditorWindow : EditorWindow |
|
|
|
namespace Fungus.Script |
|
|
|
{ |
|
|
|
{ |
|
|
|
[System.NonSerialized] |
|
|
|
|
|
|
|
public Vector2 scrollPos; // ScrollViews use a Vector2 to track the state of each scroll bar |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Sequence> windowSequenceMap = new List<Sequence>(); |
|
|
|
public class FungusEditorWindow : EditorWindow |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[System.NonSerialized] |
|
|
|
|
|
|
|
public Vector2 scrollPos; // ScrollViews use a Vector2 to track the state of each scroll bar |
|
|
|
|
|
|
|
|
|
|
|
private GameObject cachedSelection; |
|
|
|
private List<Sequence> windowSequenceMap = new List<Sequence>(); |
|
|
|
|
|
|
|
|
|
|
|
[MenuItem("Window/Fungus Editor")] |
|
|
|
private GameObject cachedSelection; |
|
|
|
static void Init() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnInspectorUpdate() |
|
|
|
[MenuItem("Window/Fungus Editor")] |
|
|
|
{ |
|
|
|
static void Init() |
|
|
|
Repaint(); |
|
|
|
{ |
|
|
|
} |
|
|
|
GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FungusScript GetFungusScript() |
|
|
|
public void OnInspectorUpdate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
GameObject activeObject = Selection.activeGameObject; |
|
|
|
Repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (activeObject != null) |
|
|
|
FungusScript GetFungusScript() |
|
|
|
{ |
|
|
|
{ |
|
|
|
FungusScript fungusScript = activeObject.GetComponent<FungusScript>(); |
|
|
|
GameObject activeObject = Selection.activeGameObject; |
|
|
|
Sequence sequence = activeObject.GetComponent<Sequence>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fungusScript != null) |
|
|
|
while (activeObject != null) |
|
|
|
{ |
|
|
|
|
|
|
|
// Found sequence controller |
|
|
|
|
|
|
|
return fungusScript; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (sequence != null && |
|
|
|
|
|
|
|
sequence.transform.parent != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check parent for sequence controller |
|
|
|
FungusScript fungusScript = activeObject.GetComponent<FungusScript>(); |
|
|
|
activeObject = sequence.transform.parent.gameObject; |
|
|
|
Sequence sequence = activeObject.GetComponent<Sequence>(); |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
activeObject = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
if (fungusScript != null) |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
// Found sequence controller |
|
|
|
|
|
|
|
return fungusScript; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (sequence != null && |
|
|
|
|
|
|
|
sequence.transform.parent != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check parent for sequence controller |
|
|
|
|
|
|
|
activeObject = sequence.transform.parent.gameObject; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
activeObject = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OnGUI() |
|
|
|
return null; |
|
|
|
{ |
|
|
|
|
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
if (fungusScript == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); |
|
|
|
void OnGUI() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
if (fungusScript == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Rect scrollViewRect = new Rect(); |
|
|
|
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (Sequence s in sequences) |
|
|
|
Rect scrollViewRect = new Rect(); |
|
|
|
{ |
|
|
|
|
|
|
|
scrollViewRect.xMin = Mathf.Min(scrollViewRect.xMin, s.nodeRect.xMin); |
|
|
|
foreach (Sequence s in sequences) |
|
|
|
scrollViewRect.xMax = Mathf.Max(scrollViewRect.xMax, s.nodeRect.xMax); |
|
|
|
{ |
|
|
|
scrollViewRect.yMin = Mathf.Min(scrollViewRect.yMin, s.nodeRect.yMin); |
|
|
|
scrollViewRect.xMin = Mathf.Min(scrollViewRect.xMin, s.nodeRect.xMin); |
|
|
|
scrollViewRect.yMax = Mathf.Max(scrollViewRect.yMax, s.nodeRect.yMax); |
|
|
|
scrollViewRect.xMax = Mathf.Max(scrollViewRect.xMax, s.nodeRect.xMax); |
|
|
|
} |
|
|
|
scrollViewRect.yMin = Mathf.Min(scrollViewRect.yMin, s.nodeRect.yMin); |
|
|
|
|
|
|
|
scrollViewRect.yMax = Mathf.Max(scrollViewRect.yMax, s.nodeRect.yMax); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Empty buffer area around edges of scroll rect |
|
|
|
// Empty buffer area around edges of scroll rect |
|
|
|
float bufferScale = 0.1f; |
|
|
|
float bufferScale = 0.1f; |
|
|
|
scrollViewRect.xMin -= position.width * bufferScale; |
|
|
|
scrollViewRect.xMin -= position.width * bufferScale; |
|
|
|
scrollViewRect.yMin -= position.height * bufferScale; |
|
|
|
scrollViewRect.yMin -= position.height * bufferScale; |
|
|
|
scrollViewRect.xMax += position.width * bufferScale; |
|
|
|
scrollViewRect.xMax += position.width * bufferScale; |
|
|
|
scrollViewRect.yMax += position.height * bufferScale; |
|
|
|
scrollViewRect.yMax += position.height * bufferScale; |
|
|
|
|
|
|
|
|
|
|
|
scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos, scrollViewRect); |
|
|
|
scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos, scrollViewRect); |
|
|
|
|
|
|
|
|
|
|
|
// In games, GUI.Window pops up a window on your screen. In the Editor, GUI.Window shows a sub-window inside an EditorWindow. |
|
|
|
// In games, GUI.Window pops up a window on your screen. In the Editor, GUI.Window shows a sub-window inside an EditorWindow. |
|
|
|
// All calls to GUI.Window need to be wrapped in a BeginWindows / EndWindows pair. |
|
|
|
// All calls to GUI.Window need to be wrapped in a BeginWindows / EndWindows pair. |
|
|
|
// http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.BeginWindows.html |
|
|
|
// http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.BeginWindows.html |
|
|
|
BeginWindows(); |
|
|
|
BeginWindows(); |
|
|
|
|
|
|
|
|
|
|
|
windowSequenceMap.Clear(); |
|
|
|
windowSequenceMap.Clear(); |
|
|
|
for (int i = 0; i < sequences.Length; ++i) |
|
|
|
for (int i = 0; i < sequences.Length; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Sequence sequence = sequences[i]; |
|
|
|
Sequence sequence = sequences[i]; |
|
|
|
sequence.nodeRect = GUILayout.Window(i, sequence.nodeRect, DrawWindow, sequence.name, GUILayout.Width(100), GUILayout.Height(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); |
|
|
|
sequence.nodeRect = GUILayout.Window(i, sequence.nodeRect, DrawWindow, sequence.name, GUILayout.Width(100), GUILayout.Height(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); |
|
|
|
windowSequenceMap.Add(sequence); |
|
|
|
windowSequenceMap.Add(sequence); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Draw connections |
|
|
|
// Draw connections |
|
|
|
foreach (Sequence s in windowSequenceMap) |
|
|
|
foreach (Sequence s in windowSequenceMap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DrawConnections(s, false); |
|
|
|
DrawConnections(s, false); |
|
|
|
} |
|
|
|
} |
|
|
|
foreach (Sequence s in windowSequenceMap) |
|
|
|
foreach (Sequence s in windowSequenceMap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DrawConnections(s, true); |
|
|
|
DrawConnections(s, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EndWindows(); |
|
|
|
EndWindows(); |
|
|
|
|
|
|
|
|
|
|
|
GUI.EndScrollView(); |
|
|
|
GUI.EndScrollView(); |
|
|
|
|
|
|
|
|
|
|
|
string labelText = fungusScript.name; |
|
|
|
string labelText = fungusScript.name; |
|
|
|
if (Application.isPlaying) |
|
|
|
if (Application.isPlaying) |
|
|
|
{ |
|
|
|
|
|
|
|
if (fungusScript.activeSequence == null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
labelText += " (Idle)"; |
|
|
|
if (fungusScript.activeSequence == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
labelText += " (Idle)"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
labelText += " (Running)"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
labelText += " (Running)"; |
|
|
|
labelText += " (Edit)"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
labelText += " (Edit)"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.BeginVertical(); |
|
|
|
GUILayout.BeginVertical(); |
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
GUILayout.BeginHorizontal(); |
|
|
|
GUILayout.BeginHorizontal(); |
|
|
|
GUILayout.Space(15); |
|
|
|
GUILayout.Space(15); |
|
|
|
if (GUILayout.Button(labelText)) |
|
|
|
if (GUILayout.Button(labelText)) |
|
|
|
{ |
|
|
|
|
|
|
|
Selection.activeGameObject = fungusScript.gameObject; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
|
|
|
|
GUILayout.EndHorizontal(); |
|
|
|
|
|
|
|
GUILayout.Space(15); |
|
|
|
|
|
|
|
GUILayout.EndVertical(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DrawWindow(int windowId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Select game object when node is clicked |
|
|
|
|
|
|
|
if (Event.current.button == 0 && |
|
|
|
|
|
|
|
Event.current.type == EventType.MouseUp) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (windowId < windowSequenceMap.Count) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Sequence s = windowSequenceMap[windowId]; |
|
|
|
Selection.activeGameObject = fungusScript.gameObject; |
|
|
|
if (s != null) |
|
|
|
} |
|
|
|
|
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
|
|
|
|
GUILayout.EndHorizontal(); |
|
|
|
|
|
|
|
GUILayout.Space(15); |
|
|
|
|
|
|
|
GUILayout.EndVertical(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DrawWindow(int windowId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Select game object when node is clicked |
|
|
|
|
|
|
|
if (Event.current.button == 0 && |
|
|
|
|
|
|
|
Event.current.type == EventType.MouseUp) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (windowId < windowSequenceMap.Count) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Selection.activeGameObject = s.gameObject; |
|
|
|
Sequence s = windowSequenceMap[windowId]; |
|
|
|
|
|
|
|
if (s != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Selection.activeGameObject = s.gameObject; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FungusCommandEditor.selectedCommand != null) |
|
|
|
if (FungusCommandEditor.selectedCommand != null) |
|
|
|
{ |
|
|
|
|
|
|
|
if (Selection.activeGameObject == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
FungusCommandEditor.selectedCommand = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
FungusCommand command = Selection.activeGameObject.GetComponent<FungusCommand>(); |
|
|
|
if (Selection.activeGameObject == null) |
|
|
|
if (command == null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
FungusCommandEditor.selectedCommand = null; |
|
|
|
FungusCommandEditor.selectedCommand = null; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (command.gameObject != FungusCommandEditor.selectedCommand.gameObject) |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
FungusCommandEditor.selectedCommand = null; |
|
|
|
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.button); |
|
|
|
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) |
|
|
|
{ |
|
|
|
|
|
|
|
string commandName = command.GetType().Name; |
|
|
|
|
|
|
|
commandName = commandName.Replace("Command", ""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (command.errorMessage.Length > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
GUI.backgroundColor = Color.red; |
|
|
|
string commandName = command.GetType().Name; |
|
|
|
} |
|
|
|
commandName = commandName.Replace("Command", ""); |
|
|
|
else if (ShouldHighlight(command)) |
|
|
|
|
|
|
|
{ |
|
|
|
if (command.errorMessage.Length > 0) |
|
|
|
if (command.IsExecuting()) |
|
|
|
{ |
|
|
|
|
|
|
|
GUI.backgroundColor = Color.red; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (ShouldHighlight(command)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GUI.backgroundColor = Color.green; |
|
|
|
if (command.IsExecuting()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GUI.backgroundColor = Color.green; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GUI.backgroundColor = Color.yellow; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
GUI.backgroundColor = Color.yellow; |
|
|
|
GUI.backgroundColor = Color.white; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
if (GUILayout.Button(commandName, style, GUILayout.ExpandWidth(true))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GUI.backgroundColor = Color.white; |
|
|
|
// Highlight the command in inspector |
|
|
|
|
|
|
|
FungusCommandEditor.selectedCommand = command; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EditorUtility.SetDirty( command ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button(commandName, style, GUILayout.ExpandWidth(true))) |
|
|
|
// Add an invisible element if there are no commands to avoid window width/height collapsing |
|
|
|
|
|
|
|
if (commands.Length == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Highlight the command in inspector |
|
|
|
GUILayout.Space(10); |
|
|
|
FungusCommandEditor.selectedCommand = command; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EditorUtility.SetDirty( command ); |
|
|
|
GUI.DragWindow(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add an invisible element if there are no commands to avoid window width/height collapsing |
|
|
|
|
|
|
|
if (commands.Length == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GUILayout.Space(10); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUI.DragWindow(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DrawConnections(Sequence sequence, bool highlightedOnly) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
List<Sequence> connectedSequences = new List<Sequence>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FungusCommand[] commands = sequence.GetComponentsInChildren<FungusCommand>(); |
|
|
|
void DrawConnections(Sequence sequence, bool highlightedOnly) |
|
|
|
foreach (FungusCommand command in commands) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
bool highlight = ShouldHighlight(command); |
|
|
|
List<Sequence> connectedSequences = new List<Sequence>(); |
|
|
|
|
|
|
|
|
|
|
|
if (highlightedOnly && !highlight || |
|
|
|
FungusCommand[] commands = sequence.GetComponentsInChildren<FungusCommand>(); |
|
|
|
!highlightedOnly && highlight) |
|
|
|
foreach (FungusCommand command in commands) |
|
|
|
{ |
|
|
|
{ |
|
|
|
continue; |
|
|
|
bool highlight = ShouldHighlight(command); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connectedSequences.Clear(); |
|
|
|
if (highlightedOnly && !highlight || |
|
|
|
command.GetConnectedSequences(ref connectedSequences); |
|
|
|
!highlightedOnly && highlight) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (Sequence sequenceB in connectedSequences) |
|
|
|
connectedSequences.Clear(); |
|
|
|
{ |
|
|
|
command.GetConnectedSequences(ref connectedSequences); |
|
|
|
Rect rectA = sequence.nodeRect; |
|
|
|
|
|
|
|
Rect rectB = sequenceB.nodeRect; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector2 pointA; |
|
|
|
foreach (Sequence sequenceB in connectedSequences) |
|
|
|
Vector2 pointB; |
|
|
|
{ |
|
|
|
|
|
|
|
Rect rectA = sequence.nodeRect; |
|
|
|
|
|
|
|
Rect rectB = sequenceB.nodeRect; |
|
|
|
|
|
|
|
|
|
|
|
Vector2 p1 = rectA.center; |
|
|
|
Vector2 pointA; |
|
|
|
Vector2 p2 = rectB.center; |
|
|
|
Vector2 pointB; |
|
|
|
GLDraw.segment_rect_intersection(rectA, ref p1, ref p2); |
|
|
|
|
|
|
|
pointA = p2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p1 = rectB.center; |
|
|
|
Vector2 p1 = rectA.center; |
|
|
|
p2 = rectA.center; |
|
|
|
Vector2 p2 = rectB.center; |
|
|
|
GLDraw.segment_rect_intersection(rectB, ref p1, ref p2); |
|
|
|
GLDraw.segment_rect_intersection(rectA, ref p1, ref p2); |
|
|
|
pointB = p2; |
|
|
|
pointA = p2; |
|
|
|
|
|
|
|
|
|
|
|
Color color = Color.grey; |
|
|
|
p1 = rectB.center; |
|
|
|
if (highlight) |
|
|
|
p2 = rectA.center; |
|
|
|
{ |
|
|
|
GLDraw.segment_rect_intersection(rectB, ref p1, ref p2); |
|
|
|
if (command.IsExecuting()) |
|
|
|
pointB = p2; |
|
|
|
{ |
|
|
|
|
|
|
|
color = Color.green; |
|
|
|
Color color = Color.grey; |
|
|
|
} |
|
|
|
if (highlight) |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
color = Color.yellow; |
|
|
|
if (command.IsExecuting()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
color = Color.green; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
color = Color.yellow; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLDraw.DrawConnectingCurve(pointA, pointB, color, 2); |
|
|
|
GLDraw.DrawConnectingCurve(pointA, pointB, color, 2); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ShouldHighlight(FungusCommand command) |
|
|
|
bool ShouldHighlight(FungusCommand command) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return (command.IsExecuting() || (FungusCommandEditor.selectedCommand == command)); |
|
|
|
return (command.IsExecuting() || (FungusCommandEditor.selectedCommand == command)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |