接入 Hud 输入提示并完善 InputModule 提示映射

This commit is contained in:
SepComet
2026-06-16 17:09:20 +08:00
committed by basil
parent e5630f0896
commit 21d0b410b6
13 changed files with 397 additions and 33 deletions
@@ -1,5 +1,6 @@
using Cysharp.Threading.Tasks;
using SepCore.Definition;
using SepCore.InputModule;
using UnityGameFramework.Runtime;
namespace SepCore.UI
@@ -13,9 +14,32 @@ namespace SepCore.UI
form.RefreshUI(context);
}
protected override void SubscribeCustomEvents()
{
GameEntry.InputModule.DeviceKindChanged += OnDeviceKindChanged;
}
protected override void UnsubscribeCustomEvents()
{
GameEntry.InputModule.DeviceKindChanged -= OnDeviceKindChanged;
}
private static HudContext BuildHudContext()
{
return new HudContext();
return new HudContext
{
MovePrompt = BuildPromptContext(InputActionId.Move)
};
}
private static string BuildPromptContext(InputActionId actionId)
{
if (GameEntry.InputModule == null || !GameEntry.InputModule.TryGetPrompt(actionId, out InputPrompt prompt))
{
return null;
}
return InputPromptTextUtility.BuildTmpText(prompt);
}
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
@@ -33,5 +57,16 @@ namespace SepCore.UI
{
Log.Info("HudFormController doesn't need UseCase");
}
private void OnDeviceKindChanged(InputDeviceKind deviceKind)
{
if (Context == null || Form == null)
{
return;
}
Context.MovePrompt = BuildPromptContext(InputActionId.Move);
Form.RefreshMovePrompt(Context.MovePrompt);
}
}
}