public static void ShowExternalInspector() { ExternalInspectorWindow.ShowWindow(); }
//node, connection inspector panel static Rect ShowInspectorGUIPanel(Graph graph, Vector2 canvasMousePos) { var inspectorPanel = default(Rect); if (Prefs.useExternalInspector) { return(inspectorPanel); } if (inspectorPanelAnimFloat.isAnimating) { willRepaint = true; } if (inspectorPanelAnimFloat.value == 0 && !inspectorPanelAnimFloat.isAnimating) { inspectorPanelPreviousSelection = null; inspectorPanelHeight = 0; return(inspectorPanel); } var inspectedElement = Prefs.animatePanels ? inspectorPanelPreviousSelection : GraphEditorUtility.activeElement; if (inspectedElement == null) { inspectorPanelHeight = 0; return(inspectorPanel); } GUI.BeginClip(canvasRect); var scrollWidth = inspectorPanelNeedsScroller ? 16 : 0; var posX = 5; var posY = PANELS_Y; var headerHeight = 30; inspectorPanel.x = Mathf.Lerp(-Prefs.inspectorPanelWidth - scrollWidth, posX, inspectorPanelAnimFloat.value); inspectorPanel.y = posY; inspectorPanel.width = Prefs.inspectorPanelWidth; inspectorPanel.height = inspectorPanelHeight; var groupRect = inspectorPanel.ExpandBy(0, 0, scrollWidth, 0); GUI.Box(groupRect, string.Empty, StyleSheet.windowShadow); //remove potential new lines. we want title to be shown as one liner here var displayName = !string.IsNullOrEmpty(inspectedElement.name) ? inspectedElement.name.Replace("\n", "") : inspectedElement.name; GUI.Box(groupRect, displayName, StyleSheet.editorPanel); var headerRect = new Rect(inspectorPanel.x, inspectorPanel.y, inspectorPanel.width, 30); var resizeRect = Rect.MinMaxRect(inspectorPanel.xMax - 2, inspectorPanel.yMin, inspectorPanel.xMax + 2, inspectorPanel.yMax); var popRect = new Rect(0, 0, 16, 16); var gearRect = new Rect(0, 0, 16, 16); popRect.center = new Vector2(inspectorPanel.xMin + 10, headerRect.center.y); gearRect.center = new Vector2(inspectorPanel.xMax - 16, headerRect.center.y); EditorGUIUtility.AddCursorRect(resizeRect, MouseCursor.ResizeHorizontal); EditorGUIUtility.AddCursorRect(popRect, MouseCursor.Link); EditorGUIUtility.AddCursorRect(gearRect, MouseCursor.Link); if (e.type == EventType.MouseDown && resizeRect.Contains(e.mousePosition)) { isResizingInspectorPanel = true; e.Use(); } if (isResizingInspectorPanel && e.type == EventType.Layout) { Prefs.inspectorPanelWidth += e.delta.x; } if (e.rawType == EventType.MouseUp) { isResizingInspectorPanel = false; } GUI.color = GUI.color.WithAlpha(0.5f); if (GUI.Button(popRect, EditorUtils.GetTempContent(Icons.minMaxIcon, "Open External Inspector"), GUIStyle.none)) { ExternalInspectorWindow.ShowWindow(); } GUI.color = Color.white; if (inspectedElement is Node) { if (GUI.Button(gearRect, EditorUtils.GetTempContent(Icons.gearPopupIcon, "Context Menu"), GUIStyle.none)) { Node.GetNodeMenu_Single(inspectedElement as Node).ShowAsContext(); } } EditorGUIUtility.AddCursorRect(headerRect, MouseCursor.Link); if (GUI.Button(headerRect, string.Empty, GUIStyle.none)) { Prefs.showNodePanel = !Prefs.showNodePanel; } GUI.BeginGroup(groupRect); if (Prefs.showNodePanel) { var contentRect = Rect.MinMaxRect(2, headerHeight, inspectorPanel.width - 2, inspectorPanel.height); var position = Rect.MinMaxRect(0, headerHeight, inspectorPanel.width + scrollWidth, Mathf.Min(inspectorPanel.height, canvasRect.height - posX)); var viewRect = Rect.MinMaxRect(0, headerHeight, inspectorPanel.width, inspectorPanel.height); inspectorPanelNeedsScroller = position.height < viewRect.height; inspectorPanelScrollPos = GUI.BeginScrollView(position, inspectorPanelScrollPos, viewRect, false, false); GUILayout.BeginArea(contentRect); if (inspectedElement is Node) { Node.ShowNodeInspectorGUI((Node)inspectedElement); } if (inspectedElement is Connection) { Connection.ShowConnectionInspectorGUI((Connection)inspectedElement); } EditorUtils.EndOfInspector(); if (e.type == EventType.Repaint) { inspectorPanelHeight = GUILayoutUtility.GetLastRect().yMax + headerHeight + 5; } GUILayout.EndArea(); GUI.EndScrollView(); } else { inspectorPanelHeight = 55; var contentRect = Rect.MinMaxRect(0, headerHeight, inspectorPanel.width, inspectorPanel.height); EditorGUIUtility.AddCursorRect(contentRect, MouseCursor.Link); if (GUI.Button(contentRect, "<b>...</b>", Styles.centerLabel)) { Prefs.showNodePanel = true; } } GUI.EndGroup(); GUI.EndClip(); inspectorPanel.x += canvasRect.x; inspectorPanel.y += canvasRect.y; return(inspectorPanel); }