diff --git a/Editor/Scripts/Editor/Windows/ImageProcessingGraphEditorWindow.cs b/Editor/Scripts/Editor/Windows/ImageProcessingGraphEditorWindow.cs index d7d9057..182eb66 100644 --- a/Editor/Scripts/Editor/Windows/ImageProcessingGraphEditorWindow.cs +++ b/Editor/Scripts/Editor/Windows/ImageProcessingGraphEditorWindow.cs @@ -14,23 +14,25 @@ namespace ImageProcessingGraph.Editor.Windows public static void Open(ImageProcessingGraphAsset asset) { - ImageProcessingGraphEditorWindow[] windows = Resources.FindObjectsOfTypeAll(); - - foreach (var w in windows) + var existingWindows = Resources.FindObjectsOfTypeAll(); + foreach (var w in existingWindows) { - w.Focus(); - return; + if (w.CurrentGraph == asset) + { + w.Focus(); // 👁 focus the OG window + return; + } } - ImageProcessingGraphEditorWindow window = - CreateWindow(typeof(ImageProcessingGraphEditorWindow), - typeof(SceneView)); - - window.titleContent = new GUIContent($"{asset.name}", EditorGUIUtility.ObjectContent(null, typeof(ImageProcessingGraphAsset)).image - ); + var window = CreateWindow(typeof(SceneView)); + window.titleContent = new GUIContent($"{asset.name}", + EditorGUIUtility.ObjectContent(null, typeof(ImageProcessingGraphAsset)).image); window.Load(asset); + window.Focus(); } + + void OnEnable() { if(currentGraph != null)