Icon
Displays a vector icon asset. Maps to UIToolkit’s native Image element with a VectorImage source. Supply a preloaded , a for Resources.Load (works in player builds), or a project-relative for Editor-only AssetDatabase loading. When multiple are provided, precedence is: first, then , then .
Constructor
Icon
Creates an Icon element.
| Parameter | Description |
|---|---|
source | A preloaded UnityEngine.UIElements.VectorImage. Takes precedence over all other sources. |
resourcePath | Path relative to a Resources/ folder. Used when is null. Works in player builds. |
svgPath | Project-relative path to a .svg asset. Editor only. Used when both and are null. |
width | Optional explicit width in logical pixels. |
height | Optional explicit height in logical pixels. |
key | An optional key for reconciliation identity. |
Properties
Height
The explicit height in logical pixels. Null means unconstrained.
ResourcePath
Path relative to any Resources/ folder (e.g. “Icons/star”). Loaded via Resources.Load<VectorImage> — works in player builds. Ignored when Source is non-null.
Source
A preloaded UnityEngine.UIElements.VectorImage. Takes precedence over ResourcePath and SvgPath.
SvgPath
Project-relative path to a .svg asset (e.g. “Assets/Icons/arrow.svg”). Loaded via AssetDatabase.LoadAssetAtPath — Editor only. Ignored when Source or ResourcePath is non-null.
Width
The explicit width in logical pixels. Null means unconstrained.