1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00
This commit is contained in:
Icarus 2019-12-09 11:11:47 +08:00
parent cf6cddeae5
commit cf59838dd0
2 changed files with 10 additions and 10 deletions

View File

@ -32,8 +32,14 @@ namespace XNodeEditor {
private Rect selectionBox; private Rect selectionBox;
private bool isDoubleClick = false; private bool isDoubleClick = false;
private Vector2 lastMousePosition; private Vector2 lastMousePosition;
private MenuPopupWindow _menuPopupWindow;
public void Controls() { public void Controls() {
if (_menuPopupWindow == null)
{
_menuPopupWindow = new MenuPopupWindow();
graphEditor.AddContextMenuItems(_menuPopupWindow);
}
wantsMouseMove = true; wantsMouseMove = true;
Event e = Event.current; Event e = Event.current;
switch (e.type) { switch (e.type) {
@ -219,12 +225,9 @@ namespace XNodeEditor {
} }
// Open context menu for auto-connection // Open context menu for auto-connection
else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) {
MenuPopupWindow menu = new MenuPopupWindow(); _menuPopupWindow.OnCloseA = _releaseDraggedConnection;
graphEditor.AddContextMenuItems(menu);
menu.OnCloseA += _releaseDraggedConnection; PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow);
PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu);
} }
_releaseDraggedConnection(); _releaseDraggedConnection();
@ -281,10 +284,8 @@ namespace XNodeEditor {
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places.
} else if (!IsHoveringNode) { } else if (!IsHoveringNode) {
autoConnectOutput = null; autoConnectOutput = null;
MenuPopupWindow menu = new MenuPopupWindow(); PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow);
graphEditor.AddContextMenuItems(menu);
PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu);
} }
} }
isPanning = false; isPanning = false;

View File

@ -106,7 +106,6 @@ namespace XNodeEditor {
void OnFocus() { void OnFocus() {
current = this; current = this;
ValidateGraphEditor(); ValidateGraphEditor();
graphEditor?.OnFocus();
if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
} }