Skip to Content

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.

ParameterDescription
sourceA preloaded UnityEngine.UIElements.VectorImage. Takes precedence over all other sources.
resourcePathPath relative to a Resources/ folder. Used when is null. Works in player builds.
svgPathProject-relative path to a .svg asset. Editor only. Used when both and are null.
widthOptional explicit width in logical pixels.
heightOptional explicit height in logical pixels.
keyAn 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.

Methods

ShouldRebuild

Last updated on