public static T FindBoundGraphViewToolWindow <T>(GraphViewBridge gv) where T : GraphViewToolWindowBridge { var guiViews = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(guiViews); FieldInfo fieldInfo = typeof(T).GetField("m_SelectedGraphView", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(fieldInfo); using (var it = UIElementsUtility.GetPanelsIterator()) { while (it.MoveNext()) { var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea; if (dockArea == null) { continue; } foreach (var graphViewTool in dockArea.m_Panes.OfType <T>()) { var usedGv = (GraphViewBridge)fieldInfo.GetValue(graphViewTool); if (usedGv == gv) { return(graphViewTool); } } } } return(null); }
public static void SpawnAttachedViewToolWindow <T>(GraphViewEditorWindowBridge window, GraphViewBridge gv) where T : GraphViewToolWindowBridge { const int newToolWidth = 200; if (!(window.m_Parent is DockArea gvDockArea)) // Should never happen { return; } var container = gvDockArea.parent; var originalSize = gvDockArea.position.size; var originalWindowPos = gvDockArea.window.position; int insertIdx = container.IndexOfChild(gvDockArea); container.RemoveChild(gvDockArea); var splitView = ScriptableObject.CreateInstance <SplitView>(); var toolDockArea = ScriptableObject.CreateInstance <DockArea>(); var toolWindow = ScriptableObject.CreateInstance <T>(); toolWindow.SelectGraphViewFromWindow(window, gv); splitView.AddChild(toolDockArea); splitView.AddChild(gvDockArea); container.AddChild(splitView, insertIdx); toolDockArea.position = new Rect(Vector2.zero, new Vector2(newToolWidth, originalSize.y)); gvDockArea.position = new Rect(Vector2.zero, new Vector2(originalSize.x - newToolWidth, originalSize.y)); splitView.position = new Rect(Vector2.zero, originalSize); container.window.position = originalWindowPos; toolDockArea.AddTab(toolWindow); container.Reflow(); }
public override void SelectGraphViewFromWindow(GraphViewEditorWindowBridge window, GraphViewBridge graphView, int graphViewIndexInWindow = 0) { var gvChoice = new GraphViewChoice { window = window, graphView = graphView as GraphView, idx = graphViewIndexInWindow }; SelectGraphView(gvChoice); }