跳转至

UI 鼠标点击设置(Set Input Mode Game And UI + Show Mouse Cursor)

让游戏运行时鼠标光标可见、可以点击 UI,同时避免鼠标输入被 UI 抢占。

解决方法

在创建 HUD 控件后(如 BeginPlay 流程中)对 Player Controller 做两步设置:

  1. Set Show Mouse Cursor(显示鼠标光标)勾选为 true,目标用 Get Player Controller(Player Index 0)。
  2. 调用 Set Input Mode Game And UI:
  3. Player Controller:接 Get Player Controller;
  4. In Widget to Focus:接 HUD 控件引用;
  5. In Mouse Lock Mode:不锁定(Do Not Lock);
  6. Hide Cursor During Capture:取消勾选;
  7. Flush Input:不勾选。

Set Input Mode Game And UI 设置

注意事项

  • 关键是 Hide Cursor During Capture 必须关掉:原笔记标注"如果不关闭这个,鼠标的输入会被抢占"。
  • 输入模式的选择规则(GameOnly / GameAndUI / UIOnly)见 UI 输入模式选择规则。

ID:43 | 更新:2026-06-11