SusUnitNameplate

面向世界空间的铭牌 —— faction 条、图标、name / level、可选 HP;可从单位 Transform 自动绑定。
包
SusKit · 世界(商业)
属性
| 名称 | 类型 | 默认值 | |
|---|---|---|---|
UnitName | Prop<string> | "" | v-model |
Level | Prop<int> | 0 | v-model |
Faction | Prop<string> | "" | v-model |
Icon | Prop<string> | "" | v-model |
HpFraction | Prop<float> | 1f | v-model |
ShowHealthBar | Prop<bool> | false | v-model |
Target | Prop<Transform> | null | v-model |
AutoBind | Prop<bool> | true | v-model |
插槽
没有插槽。
事件
没有公开事件。
样式钩子
USS 类契约 — 无需改 C# 即可覆盖外观。状态通过这些类切换:
sus-unit-nameplatesus-unit-nameplate__contentsus-unit-nameplate__factionsus-unit-nameplate__faction--allysus-unit-nameplate__faction--enemysus-unit-nameplate__faction--neutralsus-unit-nameplate__hpsus-unit-nameplate__hp-fillsus-unit-nameplate__hp-fill--criticalsus-unit-nameplate__hp-fill--warningsus-unit-nameplate__iconsus-unit-nameplate__levelsus-unit-nameplate__namesus-unit-nameplate__platesus-unit-nameplate__row
用法
手动 props(Storybook 默认值 —— AutoBind=false):
csharp
var unit = new SusUnitNameplate();
unit.UnitName.Value = "Captain";
unit.Level.Value = 12;
unit.Faction.Value = "ally";
unit.Icon.Value = "shield";
unit.HpFraction.Value = 0.55f;
unit.ShowHealthBar.Value = true;
unit.AutoBind.Value = false;xml
<template>
<sus:SusUnitNameplate :UnitName="Name.Value"
:Level="Level.Value"
:Faction="Faction.Value"
:Icon="Icon.Value"
:HpFraction="Hp.Value"
:ShowHealthBar="ShowHp.Value"
:AutoBind="AutoBind.Value" />
</template>
<script>
public Prop<string> Name = new("Captain");
public Prop<int> Level = new(12);
public Prop<string> Faction = new("ally");
public Prop<string> Icon = new("shield");
public Prop<float> Hp = new(0.55f);
public Prop<bool> ShowHp = new(true);
public Prop<bool> AutoBind = new(false);
// Optional: assign Target (Transform) + AutoBind=true to pull IWorldUnit* data.
</script>| Prop | 作用 |
|---|---|
UnitName / Level / Icon | 身份信息行 |
Faction | ally · enemy · neutral(faction 条颜色) |
HpFraction | HP 填充 0…1 |
ShowHealthBar | 切换 HP 条可见性 |
Target | 用于自动绑定的单位 Transform |
AutoBind | 为 true 且设置了 Target 时,从 IWorldUnit* 同步数据 |
备注
- 比
SusNameplate更丰富:内置 faction 条 + 图标;可选 Transform 绑定。 - HP 条始终存在于 DOM 中;通过
ShowHealthBar切换其可见性。