mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Merge pull request #222 from LumosX/occupied-autoconnection-fix
Fix autoconnection menu opening when a link cannot be established
This commit is contained in:
commit
a47b4568db
@ -58,10 +58,9 @@ namespace XNodeEditor {
|
|||||||
case EventType.MouseDrag:
|
case EventType.MouseDrag:
|
||||||
if (e.button == 0) {
|
if (e.button == 0) {
|
||||||
if (IsDraggingPort) {
|
if (IsDraggingPort) {
|
||||||
if (IsHoveringPort && hoveredPort.IsInput && draggedOutput.CanConnectTo(hoveredPort)) {
|
// Set target even if we can't connect, so as to prevent auto-conn menu from opening erroneously
|
||||||
if (!draggedOutput.IsConnectedTo(hoveredPort)) {
|
if (IsHoveringPort && hoveredPort.IsInput && !draggedOutput.IsConnectedTo(hoveredPort)) {
|
||||||
draggedOutputTarget = hoveredPort;
|
draggedOutputTarget = hoveredPort;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
draggedOutputTarget = null;
|
draggedOutputTarget = null;
|
||||||
}
|
}
|
||||||
@ -206,7 +205,7 @@ namespace XNodeEditor {
|
|||||||
//Port drag release
|
//Port drag release
|
||||||
if (IsDraggingPort) {
|
if (IsDraggingPort) {
|
||||||
// If connection is valid, save it
|
// If connection is valid, save it
|
||||||
if (draggedOutputTarget != null) {
|
if (draggedOutputTarget != null && draggedOutput.CanConnectTo(draggedOutputTarget)) {
|
||||||
XNode.Node node = draggedOutputTarget.node;
|
XNode.Node node = draggedOutputTarget.node;
|
||||||
if (graph.nodes.Count != 0) draggedOutput.Connect(draggedOutputTarget);
|
if (graph.nodes.Count != 0) draggedOutput.Connect(draggedOutputTarget);
|
||||||
|
|
||||||
@ -218,8 +217,8 @@ namespace XNodeEditor {
|
|||||||
EditorUtility.SetDirty(graph);
|
EditorUtility.SetDirty(graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Open context menu for auto-connection
|
// Open context menu for auto-connection if there is no target node
|
||||||
else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) {
|
else if (draggedOutputTarget == null && NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) {
|
||||||
GenericMenu menu = new GenericMenu();
|
GenericMenu menu = new GenericMenu();
|
||||||
graphEditor.AddContextMenuItems(menu);
|
graphEditor.AddContextMenuItems(menu);
|
||||||
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user