跳转到内容

SusHotbar

SusHotbar

物品栏快捷条 — N 个带按键标签的槽位,选中态外观,支持数字键 1…N / 方向键 / Enter。

SusGame · HUD(商业)

在 Playground 中打开

SusGame · HUD

属性

名称类型默认值
SlotCountProp<int>6
SelectedIndexProp<int>0
CooldownStyleProp<string>"Radial"

插槽

没有插槽。

事件

名称字段载荷
SlotActivatedOnSlotActivatedint
SelectionChangedOnSelectionChangedint

样式钩子

USS 类契约 — 无需改 C# 即可覆盖外观。状态通过这些类切换:

  • sus-hotbar
  • sus-hotbar__cd-wipe
  • sus-hotbar__icon
  • sus-hotbar__icon-host
  • sus-hotbar__key
  • sus-hotbar__slot
  • sus-hotbar__slot--selected
  • sus-hotbar__title

用法

csharp
var bar = new SusHotbar();
bar.SlotCount.Value = 6;
bar.SelectedIndex.Value = 0;
bar.OnSlotActivated += i => { /* use item */ };
bar.OnSelectionChanged += i => { /* highlight */ };

bar.SetSlotIcon(0, "potion");
bar.SetSlotLabel(0, "Heal");
bar.SetSlotIcon(1, "bomb");
bar.SetSlotLabel(1, "Grenade");
xml
<template>
  <sus:SusHotbar :SlotCount="Slots.Value"
                 :SelectedIndex="Selected.Value"
                 @slot-activated="OnSlotActivated"
                 @selection-changed="OnSelectionChanged" />
</template>

<script>
public Prop<int> Slots = new(6);
public Prop<int> Selected = new(0);
void OnSlotActivated(int index) { /* … */ }
void OnSelectionChanged(int index) { /* … */ }
// Call SetSlotIcon / SetSlotLabel after mount (slots rebuild on SlotCount).
</script>
Prop / API作用
SlotCount槽位数 1…10(默认 6
SelectedIndex选中的槽位(视觉 + 键盘)
SetSlotIcon(i, name)设置槽位图标
SetSlotLabel(i, text)图标下方的标题
OnSlotActivated点击 / 数字键 / Enter
OnSelectionChanged选中项变化

备注

  • SlotCount 变化时槽位会重建 —— 请在重建 / 挂载之后设置图标 / 标签。
  • 键盘操作:数字键 1…N、Home/End、方向键(漫游焦点)、空格 / Enter 激活。
  • 战斗技能优先使用 SusAbilityBar;hotbar 是物品栏快捷键的约定。