Class UITKItemIcon
Paints an item's icon into a slot or drag-ghost element, falling back to a visible placeholder when the item's template has no icon assigned.
public static class UITKItemIcon
- Inheritance
-
UITKItemIcon
- Inherited Members
Remarks
This exists because "no icon" and "no item" were drawn identically. Every item surface
wrote backgroundImage from Template.Icon and cleared it when that was null,
so an item whose art is not in yet occupied a slot that rendered completely empty. The
player could not see that the slot held anything, which made every interaction built on it
undiscoverable — there was nothing on screen to press, drag, or right-click.
The placeholder is a filled square at the element's existing size rather than a substitute sprite. A sprite would have to be authored, imported and referenced from five call sites, and would be one more asset able to go missing in exactly the situation this handles. A USS class needs none of that and cannot itself fail to load without the whole theme failing with it.
Whether the player may move an item is not the icon's business — see UITKDragObject, which used to cancel any drag carrying a null sprite. These two together are what make an art-less project playable: the drag is allowed to start, and there is something on screen to start it from.
Fields
CSS_PLACEHOLDER
USS class marking an icon element that is standing in for missing art. Defined in FishMMO-Theme.uss so every item surface draws the same placeholder.
public const string CSS_PLACEHOLDER = "fish-icon--placeholder"
Field Value
Methods
Apply(VisualElement, Sprite)
Shows sprite in icon, or the placeholder when it
is null. Call this wherever a slot is filled.
public static void Apply(VisualElement icon, Sprite sprite)
Parameters
iconVisualElementThe element that draws the icon. Null is tolerated.
spriteSpriteThe item's icon, or null if its template has none.
Clear(VisualElement)
Empties icon completely. Call this wherever a slot is cleared —
an empty slot must draw nothing at all, placeholder included.
public static void Clear(VisualElement icon)
Parameters
iconVisualElementThe element that draws the icon. Null is tolerated.