OverlayToolbar
Base class for toolbar elements intended to be drawn in an Overlay.
Read time 9 minutesLast updated 9 days ago
Definition
- Type: Class
- Namespace: UnityEditor.Overlays
- Assembly: UnityEditor.CoreModule
- Inherits from: VisualElement
- Implements: IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
public class OverlayToolbar : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
Use this class with ICreateHorizontalToolbar and ICreateVerticalToolbar to build Overlays that are dockable in toolbars.
Examples
using System.Collections.Generic;using UnityEditor;using UnityEditor.Overlays;using UnityEditor.Toolbars;using UnityEngine;using UnityEngine.UIElements;[Overlay(typeof(SceneView), "My Toolbar Overlay")]class MyOverlay : Overlay, ICreateToolbar{ public override VisualElement CreatePanelContent() { return new Label("I'm the content shown in panel mode!"); } public IEnumerable<string> toolbarElements { get { yield return MyToolbarItem.id; yield return SomeOtherToolbarItem.id; } }}[EditorToolbarElement(id, typeof(SceneView))]class SomeOtherToolbarItem : EditorToolbarToggle{ public const string id = "SomeOtherToolbarItem"; public SomeOtherToolbarItem() { icon = EditorGUIUtility.FindTexture("CustomTool"); }}// Example toolbar element with multiple controls[EditorToolbarElement(id, typeof(SceneView))]class MyToolbarItem : OverlayToolbar{ public const string id = "MyToolbarItem"; public MyToolbarItem() { var icon = AssetDatabase.LoadAssetAtPath<Texture2D>("MyIcon"); Add(new EditorToolbarButton(icon, () => { Debug.Log("Hello!"); })); Add(new EditorToolbarButton(icon, () => { Debug.Log("Hello again!"); })); SetupChildrenAsButtonStrip(); }}
Constructors
Constructor | Description |
|---|---|
| OverlayToolbar() | Create a new OverlayToolbar. |
Methods
Method | Description |
|---|---|
| SetupChildrenAsButtonStrip | Use this method to apply button strip styling to the contents of this VisualElement. |