{"id":15176764,"url":"https://github.com/sammmte/unity-toolbar-extender-ui-toolkit","last_synced_at":"2025-08-25T03:49:28.700Z","repository":{"id":228478524,"uuid":"774067969","full_name":"Sammmte/unity-toolbar-extender-ui-toolkit","owner":"Sammmte","description":"Tool for control over Unity's main toolbar","archived":false,"fork":false,"pushed_at":"2024-11-05T13:20:57.000Z","size":3444,"stargazers_count":103,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T03:30:34.691Z","etag":null,"topics":["unity","unity-editor","unity-package","unity3d","unity3d-plugin"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sammmte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-18T22:16:28.000Z","updated_at":"2025-08-08T00:36:41.000Z","dependencies_parsed_at":"2025-06-22T17:49:52.157Z","dependency_job_id":null,"html_url":"https://github.com/Sammmte/unity-toolbar-extender-ui-toolkit","commit_stats":null,"previous_names":["sammmte/unity-toolbar-extender-ui-toolkit"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Sammmte/unity-toolbar-extender-ui-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammmte%2Funity-toolbar-extender-ui-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammmte%2Funity-toolbar-extender-ui-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammmte%2Funity-toolbar-extender-ui-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammmte%2Funity-toolbar-extender-ui-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sammmte","download_url":"https://codeload.github.com/Sammmte/unity-toolbar-extender-ui-toolkit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammmte%2Funity-toolbar-extender-ui-toolkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272004325,"owners_count":24856937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["unity","unity-editor","unity-package","unity3d","unity3d-plugin"],"created_at":"2024-09-27T13:41:56.753Z","updated_at":"2025-08-25T03:49:28.646Z","avatar_url":"https://github.com/Sammmte.png","language":"C#","readme":"# Unity Toolbar Extender UI Toolkit\n\nInspired on marijnz's great [Unity Toolbar Extender](https://github.com/marijnz/unity-toolbar-extender), Unity Toolbar Extender UI Toolkit allows you to extend Unity's main toolbar using Unity's UI Toolkit.\n\n\u003c!-- TOC start (generated with https://github.com/derlin/bitdowntoc) --\u003e\n\n- [Unity Toolbar Extender UI Toolkit](#unity-toolbar-extender-ui-toolkit)\n- [Install](#install)\n   * [via npm](#via-npm)\n   * [via OpenUPM](#via-openupm)\n   * [via Git URL](#via-git-url)\n- [Getting Started](#getting-started)\n   * [Create Common Controls](#create-common-controls)\n   * [Place Them Left or Right to Play Buttons](#place-them-left-or-right-to-play-buttons)\n   * [Arrange Them](#arrange-them)\n   * [Create More Things Than Only Buttons](#create-more-things-than-only-buttons)\n   * [Create Whatever Visual Element You Want](#create-whatever-visual-element-you-want)\n   * [Don't Worry About Horizontal Space. It's Scrollable!](#dont-worry-about-horizontal-space-its-scrollable)\n   * [Important Notes](#important-notes)\n- [Prevent data loss upon entering Play mode or closing the editor](#prevent-data-loss-upon-entering-play-mode-or-closing-the-editor)\n   * [Important Notes](#important-notes-1) \n- [Group Your Elements to Save Space](#group-your-elements-to-save-space)\n   * [Make Subgroups](#make-subgroups)\n   * [Allow Subwindows](#allow-subwindows)\n   * [Important Notes](#important-notes-2)\n- [Hide Unity's Native Toolbar Visual Elements. Save Even More Space](#hide-unitys-native-toolbar-visual-elements-save-even-more-space)\n   * [Important Notes](#important-notes-3)\n- [MainToolbar Class](#maintoolbar-class)\n   * [Important Notes](#important-notes-4)\n- [Styling Your Main Toolbar Elements](#styling-your-main-toolbar-elements)\n- [Eligible Classes for Recommended Style Application](#eligible-classes-for-recommended-style-application)\n- [Miscelaneous Information](#miscelaneous-information)\n   * [About MainToolbarAutomaticExtender Class:](#about-maintoolbarautomaticextender-class)\n   * [About How This Package Saves Its Data](#about-how-this-package-saves-its-data)\n- [Tested Versions](#tested-versions)\n- [Known Issues](#known-issues)\n- [License](#license)\n\n\u003c!-- TOC end --\u003e\n\n\u003c!-- TOC --\u003e\u003ca name=\"install\"\u003e\u003c/a\u003e\n# Install\n\n\u003c!-- TOC --\u003e\u003ca name=\"via-npm\"\u003e\u003c/a\u003e\n## via npm\n\nOpen `Packages/manifest.json` with your favorite text editor. Add a [scoped registry](https://docs.unity3d.com/Manual/upm-scoped.html) and following line to dependencies block:\n```json\n{\n  \"scopedRegistries\": [\n    {\n      \"name\": \"npmjs\",\n      \"url\": \"https://registry.npmjs.org/\",\n      \"scopes\": [\n        \"com.paps\"\n      ]\n    }\n  ],\n  \"dependencies\": {\n    \"com.paps.unity-toolbar-extender-ui-toolkit\": \"1.0.0\"\n  }\n}\n```\nPackage should now appear in package manager.\n\n\u003c!-- TOC --\u003e\u003ca name=\"via-openupm\"\u003e\u003c/a\u003e\n## via OpenUPM\n\nThe package is also available on the [openupm registry](https://openupm.com/packages/com.paps.unity-toolbar-extender-ui-toolkit). You can install it eg. via [openupm-cli](https://github.com/openupm/openupm-cli).\n\n```\nopenupm add com.paps.unity-toolbar-extender-ui-toolkit\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"via-git-url\"\u003e\u003c/a\u003e\n## via Git URL\n\nOpen Package Manager window, Go to `Top left plus icon -\u003e Add package from git URL`. There add the following: `https://github.com/Sammmte/unity-toolbar-extender-ui-toolkit.git?path=/Assets/Package`\n\n\u003c!-- TOC --\u003e\u003ca name=\"getting-started\"\u003e\u003c/a\u003e\n# Getting Started\n\nIt is recommended to import package samples in your project. To do this `Open Package Manager -\u003e Filter by In Project packages -\u003e Click Unity Toolbar Extender UI Toolkit package -\u003e In package window select Samples -\u003e Click Import`.\n\n\u003c!-- TOC --\u003e\u003ca name=\"create-common-controls\"\u003e\u003c/a\u003e\n## Create Common Controls\n\nInherit from any Unity's built-in visual element, tag it with `MainToolbarElementAttribute` and define an id. You can place the script in any `Editor` folder or subfolder or in a folder with an editor assembly definition.\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(id: \"TheAwesomeButton\")]\npublic class MyAwesomeButton : Button\n{\n    //avoid constructors, create a method called \"InitializeElement\"\n    //The tool will find it, no matter the access modifier\n    //This is like an Awake method\n    public void InitializeElement()\n    {\n        text = \"Awesome Button\";\n        clicked += () =\u003e Debug.Log(\"Awesome debug\");\n    }\n}\n```\n\n![](Assets/Package/Readme-Resources~/common-button-example.png)\n\n\u003c!-- TOC --\u003e\u003ca name=\"place-them-left-or-right-to-play-buttons\"\u003e\u003c/a\u003e\n## Place Them Left or Right to Play Buttons\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(id: \"LeftButton\", ToolbarAlign.Left)]\npublic class MyLeftButton : Button\n{\n    public void InitializeElement()\n    {\n        text = \"Left Button\";\n    }\n}\n\n[MainToolbarElement(id: \"RightButton\", ToolbarAlign.Right)]\npublic class MyRightButton : Button\n{\n    public void InitializeElement()\n    {\n        text = \"Right Button\";\n    }\n}\n```\n\n![](Assets/Package/Readme-Resources~/control-alignment-example.png)\n\n\u003c!-- TOC --\u003e\u003ca name=\"arrange-them\"\u003e\u003c/a\u003e\n## Arrange Them\n\nLeft elements are ordered from right to left. Right elements from left to right.\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(id: \"FirstLeftButton\", ToolbarAlign.Left, order: 1)]\npublic class FirstLeftButton : Button\n{\n    public void InitializeElement()\n    {\n        text = \"1st Button\";\n    }\n}\n\n[MainToolbarElement(id: \"SecondLeftButton\", ToolbarAlign.Left, order: 2)]\npublic class SecondLeftButton : Button\n{\n    public void InitializeElement()\n    {\n        text = \"2nd Button\";\n    }\n}\n\n[MainToolbarElement(id: \"FirstRightButton\", ToolbarAlign.Right, order: 1)]\npublic class FirstRightButton : Button\n{\n    public void InitializeElement()\n    {\n        text = \"1st Button\";\n    }\n}\n\n[MainToolbarElement(id: \"SecondRightButton\", ToolbarAlign.Right, order: 2)]\npublic class SecondRightButton : Button\n{\n    public void InitializeElement()\n    {\n        text = \"2nd Button\";\n    }\n}\n```\n\n![](Assets/Package/Readme-Resources~/common-arrangement-example.png)\n\n\u003c!-- TOC --\u003e\u003ca name=\"create-more-things-than-only-buttons\"\u003e\u003c/a\u003e\n## Create More Things Than Only Buttons\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\nusing System.Collections.Generic;\n\n[MainToolbarElement(id: \"AwesomeToggle\", ToolbarAlign.Left)]\npublic class MyAwesomeToggle : Toggle\n{\n    public void InitializeElement()\n    {\n        label = \"Awesome Toggle\";\n    }\n}\n\n[MainToolbarElement(id: \"AwesomeDropdownField\", ToolbarAlign.Right)]\npublic class MyAwesomeDropdownField : DropdownField\n{\n    public void InitializeElement()\n    {\n        label = \"Awesome Dropdown\";\n        choices = new List\u003cstring\u003e() { \"Option 1\", \"Option 2\"};\n    }\n}\n\n[MainToolbarElement(id: \"AwesomeSlider\", ToolbarAlign.Left)]\npublic class MyAwesomeSlider : Slider\n{\n    public void InitializeElement()\n    {\n        label = \"Awesome Slider\";\n        lowValue = 0;\n        highValue = 100;\n    }\n}\n\n[MainToolbarElement(\"MyAwesomeIntField\", ToolbarAlign.Right)]\npublic class MyAwesomeIntegerField : IntegerField\n{\n    public void InitializeElement()\n    {\n        label = \"Awesome Int\";\n    }\n}\n```\n\n![](Assets/Package/Readme-Resources~/other-common-controls.png)\n\n\u003c!-- TOC --\u003e\u003ca name=\"create-whatever-visual-element-you-want\"\u003e\u003c/a\u003e\n## Create Whatever Visual Element You Want\n\nAs long as your class inherits from `VisualElement` class, you can create whatever you want.\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(id: \"AwesomeThing\")]\npublic class MyAwesomeWhatever : VisualElement\n{\n    private Toggle _displaySliderToggle;\n    private Slider _slider;\n\n    public void InitializeElement()\n    {\n        _displaySliderToggle = new Toggle(\"Display slider\");\n        _slider = new Slider(0, 100);\n\n        _displaySliderToggle.labelElement.style.minWidth = 0;\n\n        _slider.style.display = DisplayStyle.None;\n        _slider.style.minWidth = 150;\n\n        _displaySliderToggle.RegisterCallback\u003cChangeEvent\u003cbool\u003e\u003e(OnToggleValueChanged);\n\n        style.minWidth = 300;\n        style.flexDirection = FlexDirection.Row;\n\n        Add(_displaySliderToggle);\n        Add(_slider);\n    }\n\n    private void OnToggleValueChanged(ChangeEvent\u003cbool\u003e eventArgs)\n    {\n        var displayToggle = eventArgs.newValue;\n\n        if (displayToggle)\n            _slider.style.display = DisplayStyle.Flex;\n        else\n            _slider.style.display = DisplayStyle.None;\n    }\n}\n```\n\n![](Assets/Package/Readme-Resources~/custom-element-example.gif)\n\n\u003c!-- TOC --\u003e\u003ca name=\"dont-worry-about-horizontal-space-its-scrollable\"\u003e\u003c/a\u003e\n## Don't Worry About Horizontal Space. It's Scrollable!\n\n![](Assets/Package/Readme-Resources~/container-scrollable-demonstration.gif)\n\n\u003c!-- TOC --\u003e\u003ca name=\"important-notes\"\u003e\u003c/a\u003e\n## Important Notes ![](Assets/Package/Readme-Resources~/warning.png)\n\n- If you want to apply custom style to your elements, please read [Styling Your Main Toolbar Elements](#styling-your-main-toolbar-elements) section.\n- You can define a main toolbar element that inherits from `IMGUIContainer` to render stuff with `IMGUI`. Remember to use `GUILayout.BeginHorizontal` and `GUILayout.EndHorizontal` to render your things in row.\n- Main toolbar elements may be instantiated more than once, whenever `MainToolbarAutomaticExtender` refreshes. Take it into account if you need to make some heavy process with your elements.\n\n\u003c!-- TOC --\u003e\u003ca name=\"prevent-data-loss-upon-entering-play-mode-or-closing-the-editor\"\u003e\u003c/a\u003e\n# Prevent data loss upon entering Play mode or closing the editor\n\nMark a field or property with the `SerializeAttribute` to save its value whenever it changes. Otherwise if you enter Play mode or close the editor data will be reset.\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(\"AwesomeInt\")]\npublic class MyAwesomeInt : IntegerField\n{\n    [Serialize] private int _intValue;\n\n    public void InitializeElement()\n    {\n        value = _intValue; // set saved value to integer field value\n        label = \"Awesome Int\";\n\n        RegisterCallback\u003cChangeEvent\u003cint\u003e\u003e(ev =\u003e\n        {\n            _intValue = ev.newValue;\n        });\n    }\n}\n```\n\nFields and properties are serialized with their names by default.\n\nYou can set your own serialization key to prevent data loss when a field or property name changes due to, for example, refactors.\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(\"AwesomeInt\")]\npublic class MyAwesomeInt : IntegerField\n{\n    [Serialize(\"fixed-int-name\")] private int _intValue;\n\n    public void InitializeElement()\n    {\n        value = _intValue; // set saved value to integer field value\n        label = \"Awesome Int\";\n\n        RegisterCallback\u003cChangeEvent\u003cint\u003e\u003e(ev =\u003e\n        {\n            _intValue = ev.newValue;\n        });\n    }\n}\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"important-notes-1\"\u003e\u003c/a\u003e\n## Important Notes ![](Assets/Package/Readme-Resources~/warning.png)\n\n- Use `InitializeElement` method to access restored values. Don't use constructors because the system injects the serialized values once the object is created.\n- To serialize values this tool uses [Unity Serialization Package](https://docs.unity3d.com/Packages/com.unity.serialization@3.1/manual/index.html), therefore you can use its features, like `JsonAdapters` to serialize your objects the way you want. You can add a custom `JsonAdapter` from a method with `InitializeOnLoadMethod`, then add a global `JsonAdapter` (check the docs).\n- You can serialize anything `Unity Serialization Package` serializes, including dictionaries, custom classes and structs, Unity objects like GameObject, any component, etc.\n\n\u003c!-- TOC --\u003e\u003ca name=\"group-your-elements-to-save-space\"\u003e\u003c/a\u003e\n# Group Your Elements to Save Space\n\nCreate a **Group Definition** asset and group any visual element in it. They will be hidden and shown by a dropdown.\n\nTo create a **Group Definition** asset go to `Project Window -\u003e Right Click -\u003e Create -\u003e Paps -\u003e Unity Toolbar Extender UI Toolkit -\u003e Group Definition`\n\n![](Assets/Package/Readme-Resources~/group-demonstration.gif)\n\n\u003c!-- TOC --\u003e\u003ca name=\"make-subgroups\"\u003e\u003c/a\u003e\n## Make Subgroups\n\nWhen configuring `ToolbarElementsIds` property in your group definition asset, add a new element and select the id of other group asset.\n\n![](Assets/Package/Readme-Resources~/subgroup-demonstration.gif)\n\n\u003c!-- TOC --\u003e\u003ca name=\"allow-subwindows\"\u003e\u003c/a\u003e\n## Allow Subwindows\n\nGroup elements display a small window that works almost like a popup window. If your custom element displays a window, by default the group element window will be closed. To tell group element window that your window is a subwindow mark your `EditorWindow` derived class with  `GroupPopupSubWindowAttribute`. This attribute can also be used with classes derived from `PopupWindowContent`.\n\nExample with `EditorWindow`\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEditor;\nusing UnityEditor.Toolbars;\nusing UnityEngine;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(\"MyDropdownWithWindow\")]\npublic class DropdownInGroupWithWindow : EditorToolbarDropdown\n{\n    public DropdownInGroupWithWindow()\n    {\n        text = nameof(DropdownInGroupWithWindow);\n        clicked += ShowDropdownWindow;\n    }\n\n    private void ShowDropdownWindow()\n    {\n        var newWindowDropdown = ScriptableObject.CreateInstance\u003cDropdownWindow\u003e();\n        // Check important notes to know more about ShowAsDropdownForMainToolbar method\n        newWindowDropdown.ShowAsDropdownForMainToolbar(worldBound, new Vector2(200, 200));\n    }\n}\n\n[GroupPopupSubWindow]\npublic class DropdownWindow : EditorWindow\n{\n    private void CreateGUI()\n    {\n        var debugButton = new Button(() =\u003e Debug.Log(\"What a debug!\"));\n        debugButton.text = \"Debug\";\n\n        var closeButton = new Button(() =\u003e Close());\n        closeButton.text = \"Close\";\n\n        rootVisualElement.Add(debugButton);\n        rootVisualElement.Add(closeButton);\n    }\n}\n```\n\nExample with `PopupWindowContent`\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEditor;\nusing UnityEditor.Toolbars;\nusing UnityEngine;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(\"MyDropdownWithPopupWindowContent\")]\npublic class DropdownInGroupWithPopupWindow : EditorToolbarDropdown\n{\n    public DropdownInGroupWithPopupWindow()\n    {\n        text = nameof(DropdownInGroupWithPopupWindow);\n        clicked += ShowPopupWindow;\n    }\n\n    private void ShowPopupWindow()\n    {\n        UnityEditor.PopupWindow.Show(worldBound, new PopupWindowContentThatWorksInASubgroup());\n    }\n}\n\n[GroupPopupSubWindow]\npublic class PopupWindowContentThatWorksInASubgroup : PopupWindowContent\n{\n    public override void OnOpen()\n    {\n        var debugButton = new Button(() =\u003e Debug.Log(\"What a debug!\"));\n        debugButton.text = \"Debug\";\n\n        var closeButton = new Button(() =\u003e editorWindow.Close());\n        closeButton.text = \"Close\";\n\n        editorWindow.rootVisualElement.Add(debugButton);\n        editorWindow.rootVisualElement.Add(closeButton);\n    }\n\n    public override void OnGUI(Rect rect)\n    {\n        \n    }\n}\n```\n\n![](Assets/Package/Readme-Resources~/subwindow-demonstration.gif)\n\n\u003c!-- TOC --\u003e\u003ca name=\"important-notes-2\"\u003e\u003c/a\u003e\n## Important Notes ![](Assets/Package/Readme-Resources~/warning.png)\n\n- Elements inside a group don't have alignment. The `Alignment` property on visual elements marked with `MainToolbarElementAttribute` will be ignored.\n- Groups display their inner elements in column.\n- The order the inner elements are displayed is determined by the `ToolbarElementsIds` array elements order.\n- Group popup windows won't close if focused window is `UI Toolkit Debugger`, so you can analyze your elements inside these windows.\n- When showing a custom window as a dropdown, with `EditorWindow.ShowAsDropdown` method, it is recommended to use a extension method provided in this package, named `ShowAsDropdownForMainToolbar`. This method uses the original inside but applies some position adjustments that would, otherwise, render the window at a wrong position. For some reason this does not happen with `PopupWindow.Show` method.\n\n\u003c!-- TOC --\u003e\u003ca name=\"hide-unitys-native-toolbar-visual-elements-save-even-more-space\"\u003e\u003c/a\u003e\n# Hide Unity's Native Toolbar Visual Elements. Save Even More Space\n\nOpen the Main Toolbar Control Panel Window. Go to `Paps -\u003e Unity Toolbar Extender UI Toolkit -\u003e Windows -\u003e Main Toolbar Control Panel`.\n\nHide any toolbar visual element, either Unity's or yours.\n\n![](Assets/Package/Readme-Resources~/main-toolbar-control-panel-demonstration.gif)\n\n\u003c!-- TOC --\u003e\u003ca name=\"important-notes-3\"\u003e\u003c/a\u003e\n## Important Notes ![](Assets/Package/Readme-Resources~/warning.png)\n\n- `MainToolbarAutomaticExtender` hides visual elements by setting their style property `display` to `Display.None`.\n- There are 2 exceptions to the previous rule, Unity's `AccountDropdown` and `CloudButton` elements. These 2 elements can't be hidden by modifying `display` property, so the way this package hides them is by removing them from the hierarchy.\n\n\u003c!-- TOC --\u003e\u003ca name=\"maintoolbar-class\"\u003e\u003c/a\u003e\n# MainToolbar Class\n\nEverything covered in this article until now is managed by `MainToolbarAutomaticExtender` static class. If, by any chance, you don't want to manage your visual elements the way I meant, you can access the `MainToolbar` static class and manipulate Unity's main toolbar and its elements.\n\nYou can listen to `OnInitialized` event and apply your changes once initialized. To subscribe to this event you need to subscribe to it before the first editor update. The easiest way is to do it in the static constructor of a class marked with `InitializeOnLoad` attribute. You can also check the `IsAvailable` property to check if it is initialized.\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEditor;\n\n[InitializeOnLoad]\npublic static class MyOwnMainToolbarManager\n{\n    static MyOwnMainToolbarManager()\n    {\n        MainToolbar.OnInitialized += DoSomeStuff;\n    }\n\n    private static void DoSomeStuff()\n    {\n        // I do my stuff here\n    }\n}\n```\n\nYou can access Unity's toolbar visual elements, like the play buttons container, the left (where the cloud button is) or the right (where the layouts dropdown is).\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEditor;\nusing UnityEditor.Toolbars;\n\n[InitializeOnLoad]\npublic static class MyOwnMainToolbarManager\n{\n    static MyOwnMainToolbarManager()\n    {\n        MainToolbar.OnInitialized += DoSomeStuff;\n    }\n\n    private static void DoSomeStuff()\n    {\n        var myOwnPlayButton = new EditorToolbarButton(\"My Play Button\", \n            () =\u003e EditorApplication.EnterPlaymode());\n\n        MainToolbar.PlayModeButtonsContainer.Add(myOwnPlayButton);\n    }\n}\n```\n\nUnity's toolbar gets destroyed when the editor layout changes (through layout dropdown normally). When this happens `MainToolbar` class will try to get the new object. Because of this, any change made to the toolbar goes away, so you'll need to re-apply your changes. To do this, listen to `OnRefresh` event and you can do the same things you did when `OnInitialized` event happened.\n\n\u003c!-- TOC --\u003e\u003ca name=\"important-notes-4\"\u003e\u003c/a\u003e\n## Important Notes ![](Assets/Package/Readme-Resources~/warning.png)\n\n- Visual elements with `MainToolbarElementAttribute` are handled by `MainToolbarAutomaticExtender` static class. Although you could, it's not officially supported to use this feature while manipulating `MainToolbar` class directly.\n\n\u003c!-- TOC --\u003e\u003ca name=\"styling-your-main-toolbar-elements\"\u003e\u003c/a\u003e\n# Styling Your Main Toolbar Elements\n\nSome common built-in visual elements have some issues when added to the toolbar containers (e.g `Button` and `DropdownField` that are rendered with a white broken-like texture), and some other when they are added to the group element window (e.g `EditorToolbarDropdown` that doesn't render its foldout arrow).\n\nCheck this example.\n\n![](Assets/Package/Readme-Resources~/broken-element-example.jpg)\n\nTo workaround this, `MainToolbarAutomaticExtender` applies some changes to style of most of your custom visual elements when they are added either to toolbar containers or to group element windows.\n\nBecause of this, if you want to style your custom visual elements yourself you should set `MainToolbarElementAttribute` parameter `useRecommendedStyles` to `false`. Otherwise, your overrides might collide with extender's overrides. You can check if your class will be styled with recommended styles in [this list](#eligible-classes-for-recommended-style-application).\n\n```csharp\nusing Paps.UnityToolbarExtenderUIToolkit;\nusing UnityEngine.UIElements;\n\n[MainToolbarElement(id: \"StyledButton\", useRecommendedStyles: false)]\npublic class MyStyledButton : Button\n{\n    public MyStyledButton()\n    {\n        // I change the style of my button here\n    }\n}\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"eligible-classes-for-recommended-style-application\"\u003e\u003c/a\u003e\n# Eligible Classes for Recommended Style Application\n\nIf your custom main toolbar element meets at least one of the following criteria, it will be eligible to be styled with recommended styles:\n\n- Inherits from `Button` and does not inherits from `EditorToolbarButton`\n- Inherits from `Toggle` and does not inherits from `EditorToolbarToggle`\n- Inherits from `Slider`\n- Inherits from `DropdownField`\n- Inherits from `EditorToolbarDropdown`\n- Inherits from `IntegerField`\n- Inherits from `FloatField`\n- Inherits from `TextField`\n- Inherits from `EditorToolbarToggle`\n- Inherits from `Vector2Field`\n- Inherits from `Vector3Field`\n- Inherits from `ColorField`\n- Inherits from `LayerField`\n- Inherits from `EnumField`\n- Inherits from `EnumFlagsField`\n- Inherits from `TagField`\n- Inherits from `ObjectField`\n\nRemember that you can disable this feature by setting `useRecommendedStyles` to `false` in `MainToolbarElementAttribute` constructor.\n\n\u003c!-- TOC --\u003e\u003ca name=\"miscelaneous-information\"\u003e\u003c/a\u003e\n# Miscelaneous Information\n\n\u003c!-- TOC --\u003e\u003ca name=\"about-maintoolbarautomaticextender-class\"\u003e\u003c/a\u003e\n## About MainToolbarAutomaticExtender Class:\n\n- This is the main manager. Most of the magic happens inside.\n- This class **WON'T** do anything, unless you mark at least one type derived from `VisualElement` with `MainToolbarElementAttribute`.\n- When this manager initializes it applies some changes to style of native containers of Unity's main toolbar. This means that those containers behave in a way when `MainToolbarAutomaticExtender` is initialized and other way when it is not.\n\n\u003c!-- TOC --\u003e\u003ca name=\"about-how-this-package-saves-its-data\"\u003e\u003c/a\u003e\n## About How This Package Saves Its Data\n\n- This package saves json files serialized with [Unity Serialization Package](https://docs.unity3d.com/Packages/com.unity.serialization@3.1/manual/index.html) inside `UserSettings` folder. `UserSettings` is a folder that should not be under your version control (e.g. Git) and is a place to save project-and-user preferences. If you experience some weird behaviour and you suspect it could be this cache data, you can delete the related file to start over.\n\n# Tested Versions\n\nThis package was tested in:\n\n- Unity 2022.3\n    - Windows\n    - MacOS\n- Unity 6000.0\n    - Windows\n    - MacOS\n\n\u003c!-- TOC --\u003e\u003ca name=\"known-issues\"\u003e\u003c/a\u003e\n# Known Issues\n\n## MacOS\n- Input fields (e.g. `IntegerField`, `TextField`) might not work when being root toolbar objects. They work inside a group.\n- Group popup windows close when UI Toolkit Debugger window is focused.\n\n\u003c!-- TOC --\u003e\u003ca name=\"license\"\u003e\u003c/a\u003e\n# License\n\nMIT LICENSE\n        ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammmte%2Funity-toolbar-extender-ui-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammmte%2Funity-toolbar-extender-ui-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammmte%2Funity-toolbar-extender-ui-toolkit/lists"}