mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Improved reroute point size, rendering, and enabled deletion of selected points
This commit is contained in:
parent
d721249b83
commit
9f09452b43
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@ -303,6 +304,12 @@ namespace XNodeEditor {
|
||||
|
||||
/// <summary> Remove nodes in the graph in Selection.objects</summary>
|
||||
public void RemoveSelectedNodes() {
|
||||
// We need to delete reroutes starting at the highest point index to avoid shifting indices
|
||||
selectedReroutes = selectedReroutes.OrderByDescending(x => x.pointIndex).ToList();
|
||||
for (int i = 0; i < selectedReroutes.Count; i++) {
|
||||
selectedReroutes[i].RemovePoint();
|
||||
}
|
||||
selectedReroutes.Clear();
|
||||
foreach (UnityEngine.Object item in Selection.objects) {
|
||||
if (item is XNode.Node) {
|
||||
XNode.Node node = item as XNode.Node;
|
||||
|
||||
@ -216,6 +216,7 @@ namespace XNodeEditor {
|
||||
List<RerouteReference> selection = preBoxSelectionReroute != null ? new List<RerouteReference>(preBoxSelectionReroute) : new List<RerouteReference>();
|
||||
hoveredReroute = new RerouteReference();
|
||||
|
||||
Color col = GUI.color;
|
||||
foreach (XNode.Node node in graph.nodes) {
|
||||
//If a null node is found, return. This can happen if the nodes associated script is deleted. It is currently not possible in Unity to delete a null asset.
|
||||
if (node == null) continue;
|
||||
@ -249,21 +250,28 @@ namespace XNodeEditor {
|
||||
|
||||
// Loop through reroute points again and draw the points
|
||||
for (int i = 0; i < reroutePoints.Count; i++) {
|
||||
RerouteReference rerouteRef = new RerouteReference(output, k, i);
|
||||
// Draw reroute point at position
|
||||
Rect rect = new Rect(reroutePoints[i], new Vector2(16, 16));
|
||||
rect.position = new Vector2(rect.position.x - 8, rect.position.y - 8);
|
||||
Rect rect = new Rect(reroutePoints[i], new Vector2(12, 12));
|
||||
rect.position = new Vector2(rect.position.x - 6, rect.position.y - 6);
|
||||
rect = GridToWindowRect(rect);
|
||||
Color bgcol = new Color32(90, 97, 105, 255);;
|
||||
if (selectedReroutes.Contains(new RerouteReference(output, k, i))) bgcol = Color.yellow;
|
||||
NodeEditorGUILayout.DrawPortHandle(rect, bgcol, connectionColor);
|
||||
|
||||
if (rect.Overlaps(selectionBox)) selection.Add(new RerouteReference(output, k, i));
|
||||
if (rect.Contains(mousePos)) hoveredReroute = new RerouteReference(output, k, i);
|
||||
// Draw selected reroute points with an outline
|
||||
if (selectedReroutes.Contains(rerouteRef)) {
|
||||
GUI.color = NodeEditorPreferences.GetSettings().highlightColor;
|
||||
GUI.DrawTexture(rect, NodeEditorResources.dotOuter);
|
||||
}
|
||||
|
||||
GUI.color = connectionColor;
|
||||
GUI.DrawTexture(rect, NodeEditorResources.dot);
|
||||
if (rect.Overlaps(selectionBox)) selection.Add(rerouteRef);
|
||||
if (rect.Contains(mousePos)) hoveredReroute = rerouteRef;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUI.color = col;
|
||||
if (Event.current.type != EventType.Layout && currentActivity == NodeActivity.DragGrid) selectedReroutes = selection;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user