internal static void DoContextualToolbarOverlay() { GUILayout.BeginHorizontal(GUIStyle.none, GUILayout.MinWidth(210), GUILayout.Height(30)); EditorToolManager.GetComponentToolsForSharedTracker(s_EditorToolModes); if (s_EditorToolModes.Count > 0) { EditorGUI.BeginChangeCheck(); EditorGUILayout.EditorToolbar(s_EditorToolModes); if (EditorGUI.EndChangeCheck()) { foreach (var inspector in InspectorWindow.GetInspectors()) { foreach (var editor in inspector.tracker.activeEditors) { editor.Repaint(); } } } } else { var fontStyle = EditorStyles.label.fontStyle; EditorStyles.label.fontStyle = FontStyle.Italic; GUILayout.Label(Styles.noToolsAvailable, EditorStyles.centeredGreyMiniLabel); EditorStyles.label.fontStyle = fontStyle; } GUILayout.EndHorizontal(); }
void Refresh() { for (int i = childCount - 1; i > -1; i--) { RemoveAt(i); } AddToClassList("toolbar-contents"); if ((EditorToolManager.GetCustomEditorToolsCount(false) + EditorToolManager.availableComponentContextCount) < 1) { return; } EditorToolManager.GetComponentToolsForSharedTracker(s_EditorTools); s_SortedTools.Clear(); // Display available tools grouped by their target component foreach (var tool in s_EditorTools) { var component = tool.target; if (component == null) { continue; } if (!s_SortedTools.TryGetValue(component, out List <EditorTool> editorTools)) { editorTools = new List <EditorTool>(); s_SortedTools.Add(component, editorTools); } editorTools.Add(tool); } foreach (var kvp in s_SortedTools) { var tools = new VisualElement() { name = "Component Tools" }; tools.AddToClassList("toolbar-contents"); foreach (var tool in kvp.Value) { tools.Add(new ComponentToolButton <EditorTool>(tool)); } EditorToolbarUtility.SetupChildrenAsButtonStrip(tools); Add(tools); } }