From b1e0767d91dc3b6f6cb40e34e6f4cd5fbc02fcaf Mon Sep 17 00:00:00 2001 From: Chromium <62724067+Chromum@users.noreply.github.com> Date: Sat, 3 May 2025 07:23:00 +0100 Subject: [PATCH] 4 magladore! --- Editor/Scripts/Editor/ImageProcessingGraphAsset.cs | 2 +- .../ImageProcessingGraphEdgeConnectorListener.cs | 7 +++++-- .../Editor/Windows/ImageProcessingGraphViewWindow.cs | 11 ++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Editor/Scripts/Editor/ImageProcessingGraphAsset.cs b/Editor/Scripts/Editor/ImageProcessingGraphAsset.cs index 7c1e3e9..1a48d78 100644 --- a/Editor/Scripts/Editor/ImageProcessingGraphAsset.cs +++ b/Editor/Scripts/Editor/ImageProcessingGraphAsset.cs @@ -83,7 +83,7 @@ namespace ImageProcessingGraph.Editor AssetDatabase.Refresh(); } - public List<(BaseImageNode node, System.Type type)> GetAllVariableNodesWithTypes() + public List<(BaseImageNode node, System.Type type)> GetAllVariableNodesWithTypes() { var result = new List<(BaseImageNode node, System.Type type)>(); diff --git a/Editor/Scripts/Editor/Windows/ImageProcessingGraphEdgeConnectorListener.cs b/Editor/Scripts/Editor/Windows/ImageProcessingGraphEdgeConnectorListener.cs index 7c1b330..5d3b7a8 100644 --- a/Editor/Scripts/Editor/Windows/ImageProcessingGraphEdgeConnectorListener.cs +++ b/Editor/Scripts/Editor/Windows/ImageProcessingGraphEdgeConnectorListener.cs @@ -26,9 +26,12 @@ namespace ImageProcessingGraph.Editor.Unity_Image_Processing.Scripts.Editor.Wind public void OnDropOutsidePort(Edge edge, Vector2 position) { window.searchProvider.target = (VisualElement)window.focusController.focusedElement; + + var mousePos = + window.ChangeCoordinatesTo(window, window.cachedMousePos - window.Window.position.position); + var graphMousePosition = window.contentViewContainer.WorldToLocal(mousePos); - // ⚡ Override the search window open with a customized search tree - SearchWindow.Open(new SearchWindowContext(position), new ImageProcessingGraphSearchProvider.CustomSearchProviderForEdge(window.searchProvider, edge, (IPTPort)edge.input, (IPTPort)edge.output)); + SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), new ImageProcessingGraphSearchProvider.CustomSearchProviderForEdge(window.searchProvider, edge, (IPTPort)edge.input, (IPTPort)edge.output)); // Remove connections as you did List connections = new List(); diff --git a/Editor/Scripts/Editor/Windows/ImageProcessingGraphViewWindow.cs b/Editor/Scripts/Editor/Windows/ImageProcessingGraphViewWindow.cs index 36390f7..c30024c 100644 --- a/Editor/Scripts/Editor/Windows/ImageProcessingGraphViewWindow.cs +++ b/Editor/Scripts/Editor/Windows/ImageProcessingGraphViewWindow.cs @@ -27,6 +27,8 @@ namespace ImageProcessingGraph.Editor internal ImageProcessingGraphEdgeConnectorListener edgeConnectorListener; private bool isDropdownEnabled = false; + public Vector2 cachedMousePos; + private Button debugModeButton; private Button outputRunOrder; @@ -76,8 +78,15 @@ namespace ImageProcessingGraph.Editor graphViewChanged += OnGraphViewChanged; Undo.undoRedoPerformed += UndoRedoPerformed; + RegisterCallback(OnMouseMove); } - + + private void OnMouseMove(MouseMoveEvent evt) + { + cachedMousePos = evt.localMousePosition; + } + + private void UndoRedoPerformed() { DrawNodes();