1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

Selected Node on top

This commit is contained in:
Kailey Joanette 2020-04-27 18:18:43 -04:00
parent d9d90f0f7b
commit bcb65a1788
2 changed files with 16 additions and 1 deletions

View File

@ -11,6 +11,7 @@ namespace XNodeEditor {
public NodeGraphEditor graphEditor; public NodeGraphEditor graphEditor;
private List<UnityEngine.Object> selectionCache; private List<UnityEngine.Object> selectionCache;
private List<XNode.Node> culledNodes; private List<XNode.Node> culledNodes;
private List<int> orderedNodeIndices = new List<int>();
/// <summary> 19 if docked, 22 if not </summary> /// <summary> 19 if docked, 22 if not </summary>
private int topPadding { get { return isDocked() ? 19 : 22; } } private int topPadding { get { return isDocked() ? 19 : 22; } }
/// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary> /// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary>
@ -24,6 +25,14 @@ namespace XNodeEditor {
ValidateGraphEditor(); ValidateGraphEditor();
Controls(); Controls();
// Ensure we have all node indices covered
while (orderedNodeIndices.Count < graph.nodes.Count)
orderedNodeIndices.Add(orderedNodeIndices.Count);
while (orderedNodeIndices.Count > graph.nodes.Count) {
int removeIndex = orderedNodeIndices.IndexOf( orderedNodeIndices.Count - 1 );
orderedNodeIndices.RemoveAt( removeIndex );
}
DrawGrid(position, zoom, panOffset); DrawGrid(position, zoom, panOffset);
DrawConnections(); DrawConnections();
DrawDraggedConnection(); DrawDraggedConnection();
@ -412,7 +421,8 @@ namespace XNodeEditor {
List<XNode.NodePort> removeEntries = new List<XNode.NodePort>(); List<XNode.NodePort> removeEntries = new List<XNode.NodePort>();
if (e.type == EventType.Layout) culledNodes = new List<XNode.Node>(); if (e.type == EventType.Layout) culledNodes = new List<XNode.Node>();
for (int n = 0; n < graph.nodes.Count; n++) { //for (int n = 0; n < graph.nodes.Count; n++) {
foreach (int n in orderedNodeIndices) {
// Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable. // Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable.
if (graph.nodes[n] == null) continue; if (graph.nodes[n] == null) continue;
if (n >= graph.nodes.Count) return; if (n >= graph.nodes.Count) return;

View File

@ -175,6 +175,11 @@ namespace XNodeEditor {
selection.Add(node); selection.Add(node);
Selection.objects = selection.ToArray(); Selection.objects = selection.ToArray();
} else Selection.objects = new Object[] { node }; } else Selection.objects = new Object[] { node };
int nodeIndex = graph.nodes.IndexOf( node );
int indexToMove = orderedNodeIndices.IndexOf( nodeIndex );
orderedNodeIndices.RemoveAt( indexToMove );
orderedNodeIndices.Insert( orderedNodeIndices.Count, nodeIndex );
} }
public void DeselectNode(XNode.Node node) { public void DeselectNode(XNode.Node node) {