Describes the content and behaviour of a main toolbar element.
The main toolbar uses these descriptors to create and update its toolbar elements.
Additional resources: MainToolbarButton, MainToolbarToggle, MainToolbarDropdown.
using UnityEditor; using UnityEditor.Toolbars; using UnityEngine; public class MainToolbarButtonExample { [MainToolbarElement("Examples/Open Project Settings", defaultDockPosition = MainToolbarDockPosition.Middle)] public static MainToolbarElement ProjectSettingsButton() { var icon = EditorGUIUtility.IconContent("SettingsIcon").image as Texture2D; var content = new MainToolbarContent(icon); return new MainToolbarButton(content, () => { SettingsService.OpenProjectSettings(); }); } }
Property | Description |
---|---|
content | The MainToolbarContent describes the content of a main toolbar element. For example, text, icon, or tooltip. |
displayed | Specifies whether the `VisualElement` for this toolbar element should be displayed or not. Set to `True` by default. |
enabled | Specifies whether a toolbar element should receive input events. Set to `True` by default. |
populateContextMenu | Add content to the context menu that appears when you right-click this toolbar element. |