Class ToolbarBreadcrumbs
Creates a breadcrumb UI element for the toolbar to help users navigate a hierarchy. For example, the visual scripting breadcrumb toolbar makes it easier to explore scripts because users can jump to any level of the script by clicking a breadcrumb item.
Inherited Members
Namespace: UnityEditor.UIElements
Syntax
public class ToolbarBreadcrumbs : VisualElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle
Remarks
Represents a breadcrumb trail to facilitate navigation between related items in a hierarchy.
Examples
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
public class CreateBreadcrumbsHelper
{
ToolbarBreadcrumbs breadcrumbs;
public void CreateBreadcrumbs(VisualElement root)
{
var toolbar = new Toolbar();
root.Add(toolbar);
breadcrumbs = new ToolbarBreadcrumbs();
toolbar.Add(breadcrumbs);
breadcrumbs.PushItem("myItemGrandParent", GoToRoot);
breadcrumbs.PushItem("myItemParent", () => breadcrumbs.PopItem());
breadcrumbs.PushItem("myItem");
}
void GoToRoot()
{
while (breadcrumbs.childCount > 1)
breadcrumbs.PopItem();
}
}
Constructors
ToolbarBreadcrumbs()
Constructs a breadcrumb UI element for the toolbar to help users navigate a hierarchy.
Declaration
public ToolbarBreadcrumbs()
Fields
firstItemClassName
A Unity style sheet (USS) class for the first element or item in a breadcrumb toolbar.
Declaration
public static readonly string firstItemClassName
Field Value
Type | Description |
---|---|
String |
itemClassName
A Unity style sheet (USS) class for individual items in a breadcrumb toolbar.
Declaration
public static readonly string itemClassName
Field Value
Type | Description |
---|---|
String |
ussClassName
A Unity style sheet (USS) class for the main ToolbarBreadcrumbs container.
Declaration
public static readonly string ussClassName
Field Value
Type | Description |
---|---|
String |
Methods
PopItem()
Removes the last item in the breadcrumb toolbar, which is the deepest item in the hierarchy.
Declaration
public void PopItem()
PushItem(String, Action)
Adds an item to the end of the breadcrumbs, which makes that item the deepest item in the hierarchy.
Declaration
public void PushItem(string label, Action clickedEvent = null)
Parameters
Type | Name | Description |
---|---|---|
String | label | The text to display for the item in the breadcrumb toolbar. |
Action | clickedEvent | The action to perform when the a users clicks the item in the toolbar. |