Toolbar buttons
WorkspaceToolbar is a row at the top of the workspace. The workspace viewport starts below it. Buttons that do not fit go to a new row.
WorkspaceToolbarButton opens the window with its window-id. If the window is open, it focuses it.
Video tutorial: Toolbar and windows. All videos: Video tutorials.
<tb:Workspace>
<tb:WorkspaceToolbar>
<tb:WorkspaceToolbarButton window-id="Inventory" title="Inventory" />
<ui:Button name="arrange" text="Arrange" class="tb-toolbar-button" />
</tb:WorkspaceToolbar>
</tb:Workspace>
WorkspaceToolbarButton attribute |
Meaning |
|---|---|
window-id |
Id of the window to open. |
title |
Button text, used when text is not set. |
For other commands, put a normal Button in the toolbar and handle clicked:
using UIToolbox;
using UIToolbox.Utils;
using UnityEngine.UIElements;
public static class ToolbarSetup
{
public static void Bind(Workspace workspace)
{
var arrange = workspace.Q<Button>("arrange");
arrange.clicked += () => AsyncRunner.Run(() => workspace.AutoArrangeAsync(), "Auto arrange");
}
}