HotBarSlotUI

Individual hotbar slot UI element. Displays an item icon and toggles between normal/active background sprites to indicate the currently selected slot.

Definition

Namespace: Paragon.Townskeep.HUD Assembly: Townskeep.dll

public class HotBarSlotUI : ParagonUIBehaviour

Inheritance: SerializedMonoBehaviourParagonBehaviourParagonUIBehaviourHotBarSlotUI

Remarks

HotBarSlotUI represents a single slot in the hotbar. It manages two visual concerns:

  1. Selection state — Swaps the background Image sprite between Normal and Active to indicate whether this slot is currently selected.

  2. Item display — Shows or hides an item icon Image and sets it to the item's Icon sprite.

The component expects a specific child hierarchy (found via transform.Find in Awake()):

  • A child named "Background" with an Image component

  • A child named "Item" with an Image component

HotBarSlotUI is driven by HotBarHUD, which discovers all slot children via GetComponentsInChildren<HotBarSlotUI>() and calls the appropriate methods when inventory or selection state changes.

Quick Lookup

Goal
How

Show an item in the slot

slot.SetItem(item)

Clear the slot

slot.Clear()

Highlight as selected

slot.OnActivated()

Remove selection highlight

slot.OnDeactivated()

Fields

Normal

Background sprite for the unselected state.

Active

Background sprite for the selected state.

Methods

Awake

Resolves the Background and Item child Image components via transform.Find().

OnActivated

Sets the background sprite to Active, indicating this slot is the current selection.

OnDeactivated

Sets the background sprite to Normal, indicating this slot is no longer selected.

SetItem

Displays an item in the slot by activating the icon GameObject and setting the sprite to the item's Icon.

Parameter
Type
Description

item

Item

The item to display

amount

int

Item amount (currently unused visually, default: 1)

circle-info

The amount parameter is accepted but not currently rendered. The slot displays the item icon only, without a quantity label.

Clear

Hides the item icon by deactivating the icon GameObject and resetting its sprite to the background sprite.

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

  • HotBarHUD — parent element that manages all slots

  • HUDElement — base class for HUD panels

  • Item — the item type displayed in slots

Last updated