UIHotkeyGroup - jimdroberts/FishMMO GitHub Wiki
A small UI container for a single hotkey slot that groups the UIHotkeyButton
, its label, and cooldown slider. Initializes and cleans up links between the button and the cooldown mask.
-
public UIHotkeyButton Button
The
UIHotkeyButton
instance contained by this group. -
public TMP_Text Label
Text component showing the hotkey label/key.
-
public Slider CooldownMask
Slider used by the button to visually indicate cooldown progress.
-
private void Awake()
Called on initialization. Links the
CooldownMask
to theButton
and resets its value to 0. -
private void OnDestroy()
Called when the group is destroyed. Unlinks the
CooldownMask
from theButton
and resets theHotkeySlot
.
- Create a hotkey group prefab containing a
UIHotkeyButton
,TMP_Text
label, and aSlider
for cooldown. - Assign references to the
Button
,Label
, andCooldownMask
in the prefab inspector. - Instantiate the prefab under a
UIHotkeyBar
to populate hotkey slots.
var group = Instantiate(hotkeyGroupPrefab, parent).GetComponent<UIHotkeyGroup>();
group.Label.text = "1"; // or use UIHotkeyBar to set labels
// UIHotkeyGroup will automatically link the slider to the button for cooldown visuals.
- Keep visual elements lightweight; the cooldown slider is updated frequently and should not cause GC churn.
- Use a consistent prefab layout so labels and icons align across all hotkeys.
- Rely on
UIHotkeyBar.AddHotkeys
to initialize slots; avoid manual runtime manipulation unless necessary.