MainToolbarCustomElement
Describes a main toolbar element that wraps an arbitrary `VisualElement`.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Class
- Namespace: UnityEditor.Toolbars
- Assembly: UnityEditor
- Inherits from: MainToolbarElement
[Icon("UIToolkit/Icons/CustomCSharpElement.png")]public sealed class MainToolbarCustomElement : MainToolbarElement
Remarks
Use this class to add a main toolbar element whose content doesn't match any of the other MainToolbarElement types, such as MainToolbarButton or MainToolbarToggle. To add a custom element to the main toolbar use a static method registered with MainToolbarElementAttribute to return this class.
Examples
using UnityEditor;using UnityEditor.Toolbars;using UnityEngine.UIElements;public class MainToolbarCustomElementExample{ [MainToolbarElement("Examples/Custom Clock", defaultDockPosition = MainToolbarDockPosition.Middle)] public static MainToolbarElement ClockElement() { return new MainToolbarCustomElement(() => { var label = new Label(); label.schedule.Execute(() => label.text = System.DateTime.Now.ToLongTimeString()).Every(1000); return label; }); }}
Constructors
Constructor | Description |
|---|---|
| MainToolbarCustomElement(System.Func{UnityEngine.UIElements.VisualElement}) | Specify the |