Class ScyllaIconPreview
A square UnityEngine.UIElements.VisualElement that displays a Unity editor icon by name,
resolving it via FindTexture(string) with a fallback to
IconContent(string). Replaces the deleted IMGUI
IconPreviewWidget.
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public sealed class ScyllaIconPreview : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
Icon names follow the Unity built-in icon naming convention (e.g.,
"d_Console", "d_Hierarchy", "d_Prefab Icon"). The
d_ prefix selects the dark-theme variant; supply the name without the
prefix for the light-theme version.
When neither lookup succeeds the element is left with no background image and occupies an empty square of the requested size.
The element sets style.flexShrink = 0 so it does not compress when
placed inside a flex row alongside text labels.
Constructors
ScyllaIconPreview(string, float)
Creates a new icon preview element, immediately loading and displaying the
specified icon. The element is square (size x
size pixels) and does not shrink inside a flex container.
Declaration
public ScyllaIconPreview(string iconName, float size = 16)
Parameters
| Type | Name | Description |
|---|---|---|
| string | iconName | The Unity editor icon name passed to FindTexture(string)
(e.g., |
| float | size | Width and height of the icon in pixels. Default: 16. |
Methods
SetIcon(string, float)
Updates the icon displayed by this element. The element size is only updated
when size is greater than zero; otherwise the current size
is preserved. Uses the same two-stage lookup as the constructor.
Declaration
public void SetIcon(string iconName, float size = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | iconName | The Unity editor icon name. Resolved first via
FindTexture(string), then via
IconContent(string) if the first lookup returns
|
| float | size | New width and height in pixels. Pass |