跳转到内容

SusInteractPrompt

SusInteractPrompt

单条交互提示——按键徽标 + 文本;点击 / 键盘触发 OnInteract

SusGame · HUD(商业)

在 Playground 中打开

SusGame · HUD

属性

名称类型默认值
KeyProp<string>"E"
TextProp<string>"Interact"
VisibleProp<bool>true
BindActionProp<string>(string)null

插槽

没有插槽。

事件

名称字段载荷
InteractOnInteract

样式钩子

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

  • sus-interact-prompt
  • sus-interact-prompt__key
  • sus-interact-prompt__text
  • sus-interact-prompt--hidden

用法

csharp
var prompt = new SusInteractPrompt();
prompt.Key.Value = "E";
prompt.Text.Value = "Open door";
prompt.Visible.Value = true;
prompt.OnInteract += () => { /* use / open */ };
xml
<template>
  <sus:SusInteractPrompt :Key="Key.Value"
                         :Text="Label.Value"
                         :Visible="Show.Value"
                         @interact="OnInteract" />
</template>

<script>
public Prop<string> Key = new("E");
public Prop<string> Label = new("Open door");
public Prop<bool> Show = new(true);
void OnInteract() { /* … */ }
</script>
Prop / APIRole
Key徽标文本(默认 E
Text操作文本(渲染为 — {Text}
Visible切换 --hiddendisplay: none
OnInteract点击或键盘激活

备注

  • 可见时键盘处理器接受 E / Space / Enter(徽标 Key 只是显示;激活按键在组件内固定)。
  • 通过 SetPrompts / AddPromptSusPromptBar 中承载多条提示。