Toolbox controls
The UIToolbox namespace has controls that UI Toolkit does not have. They work in any panel, with or without a workspace:
- When a toolbox control attaches to a panel, it adds
UIToolbox/Themes/dark(the base palette) andUIToolbox/Styles/Controlsto the panel root. In the editor, it also adds them to the editor window and the Inspector, so a toolbox control works in a custom Inspector too. See Toolbox controls in the Inspector. - Inside a workspace, the control gets the workspace theme, because the theme variables inherit.
- Their rules use only the
--tb-*variables. See Theme variables. The classes of a control are in the Styling section of its document. - A control that uses the arrow directions acts on the
NavigationMoveEvent, not on an arrowKeyDownEvent. At runtime the arrow keys and the gamepad directions both send it, so a gamepad changes the value too. The control keeps the focus only for the directions that it uses; the other directions and Tab move the focus as usual.
Pictures: PNG or SVG
A toolbox control that shows a picture takes a PNG (a Texture2D or a Sprite) or an SVG. Unity imports an .svg file as a VectorImage when the importer of the file is "UI Toolkit Vector Image". An SVG stays sharp at any size, so it suits icons, portraits and pictures that scale with the screen.
- A property of the type
Backgroundtakes an SVG withBackground.FromVectorImage(vector). In UXML and in UI Builder, drag the.svgasset into the attribute. - A class that has a
Texture2Dproperty has aVectorImageproperty beside it, such asChoiceItem.VectorIconandDialogueLine.VectorPortrait. The SVG shows when both are set. - An SVG keeps the colors of the file. A tint color does not change it, except in a control that says so.