public static GraphWindow Show (Graph graph) { GraphWindow window = null; GraphWindow[] allWindows = Resources.FindObjectsOfTypeAll<GraphWindow>(); //if opened as biome via focused graph window - opening as biome if (focusedWindow is GraphWindow focWin && focWin.graph.ContainsSubGraph(graph)) { focWin.OpenBiome(graph); return focWin; } //if opened only one window - using it (and trying to load mm biomes) if (window == null) { if (allWindows.Length == 1) { window = allWindows[0]; if (!window.TryOpenMapMagicBiome(graph)) window.OpenRoot(graph); } } //if window with this graph currently opened - just focusing it if (window == null) { for (int w=0; w<allWindows.Length; w++) if (allWindows[w].graph == graph) window = allWindows[w]; } //if the window with parent graph currently opened if (window == null) { for (int w=0; w<allWindows.Length; w++) if (allWindows[w].graph.ContainsSubGraph(graph)) { window = allWindows[w]; window.OpenBiome(graph); } } //if no window found after all - creating new tab (and trying to load mm biomes) if (window == null) { window = CreateInstance<GraphWindow>(); if (!window.TryOpenMapMagicBiome(graph)) window.OpenRoot(graph); } ShowWindow(window, inTab:false); return window; }
public static GraphWindow ShowInNewTab (Graph graph) { GraphWindow window = CreateInstance<GraphWindow>(); window.OpenRoot(graph); ShowWindow(window, inTab:true); return window; }