UIHotkeyGroup - jimdroberts/FishMMO GitHub Wiki

Description

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.


API Access

Fields

  • 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.

Methods

  • private void Awake()

    Called on initialization. Links the CooldownMask to the Button and resets its value to 0.

  • private void OnDestroy()

    Called when the group is destroyed. Unlinks the CooldownMask from the Button and resets the HotkeySlot.


Basic Usage

Setup

  1. Create a hotkey group prefab containing a UIHotkeyButton, TMP_Text label, and a Slider for cooldown.
  2. Assign references to the Button, Label, and CooldownMask in the prefab inspector.
  3. Instantiate the prefab under a UIHotkeyBar to populate hotkey slots.

Example

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.

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️