跳转到内容

SusHudPlayerStatus

SusHudPlayerStatus

玩家身份区块 — 头像、名称,以及 HP / MP / XP 进度条行。

SusGame · HUD(商业)

在 Playground 中打开

SusGame · HUD

属性

名称类型默认值
PlayerNameProp<string>"Player"
AvatarImageProp<string>""
AvatarTextProp<string>"P"
HpProp<float>100f
HpMaxProp<float>100f
MpProp<float>100f
MpMaxProp<float>100f
XpProp<float>0f
XpMaxProp<float>100f
ShowMpProp<bool>true
ShowXpProp<bool>true

插槽

没有插槽。

事件

没有公开事件。

样式钩子

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

  • sus-hud-player-status
  • sus-hud-player-status__avatar
  • sus-hud-player-status__bar
  • sus-hud-player-status__bar-label
  • sus-hud-player-status__bars
  • sus-hud-player-status__name
  • sus-hud-player-status__row

用法

csharp
var status = new SusHudPlayerStatus();
status.PlayerName.Value = "Hero";
status.AvatarText.Value = "H";
status.AvatarImage.Value = "";
status.Hp.Value = 72f;
status.HpMax.Value = 100f;
status.Mp.Value = 40f;
status.MpMax.Value = 100f;
status.Xp.Value = 55f;
status.XpMax.Value = 100f;
status.ShowMp.Value = true;
status.ShowXp.Value = true;
xml
<template>
  <sus:SusHudPlayerStatus :PlayerName="Name.Value"
                          :AvatarImage="AvatarImg.Value"
                          :AvatarText="AvatarTxt.Value"
                          :Hp="Hp.Value"
                          :HpMax="HpMax.Value"
                          :Mp="Mp.Value"
                          :MpMax="MpMax.Value"
                          :Xp="Xp.Value"
                          :XpMax="XpMax.Value"
                          :ShowMp="ShowMp.Value"
                          :ShowXp="ShowXp.Value" />
</template>

<script>
public Prop<string> Name = new("Hero");
public Prop<string> AvatarImg = new("");
public Prop<string> AvatarTxt = new("H");
public Prop<float> Hp = new(72f);
public Prop<float> HpMax = new(100f);
public Prop<float> Mp = new(40f);
public Prop<float> MpMax = new(100f);
public Prop<float> Xp = new(55f);
public Prop<float> XpMax = new(100f);
public Prop<bool> ShowMp = new(true);
public Prop<bool> ShowXp = new(true);
</script>
Prop作用
PlayerName名称标签
AvatarImageSusAvatar 使用的图片 URL / 资源
AvatarText后备字符;为空 → 使用 PlayerName
Hp / HpMax生命值条
Mp / MpMax法力值条(ShowMp 为 false 时隐藏)
Xp / XpMax经验值条(ShowXp 为 false 时隐藏)
ShowMp · ShowXp切换 MP / XP 行的显示

备注

  • 进度条会被限制在 [0, Max] 范围内,且 Max ≥ 1
  • 基于 kit 的 SusAvatar + SusProgressLinear 构建 —— 主题令牌从 SusKit 级联而来。
  • 需要世界空间追踪的单位铭牌时使用 SusUnitNameplate,而不是这个 HUD 区块。