ContentExamplesプロジェクトのUI_CommonUIレベルのEnhancedInputのサンプルにおいて、「Triggering Enhanced Input Action」を設定したButtonをHold(長押し)でトリガーさせる方法について。

【環境】

  • Windows11
  • UE5.6 ランチャー版
  • ContentExamplesプロジェクト
  • ゲームパッド:XBoxOneコントローラ

お世話になっております。

本質問は以前質問させていただいた以下の件の続きのような話です。

  • [以前の質問]:[ContentExamplesプロジェクトのUI_CommonUIレベルのEnhancedInputのサンプルにおいて、「Triggering Enhanced Input [Content removed]

ContentExamplesプロジェクトのUI_CommonUIレベルのEnhancedInputのサンプルにおいて、「Triggering Enhanced Input Action」を設定したButtonをHold(長押し)でトリガーさせる方法について教えていただきたいです。

【事前準備】

1: ProjectSettings → CommonInputSettingsで、「Enable Enhanced Input Support」をTrueにします。

[Image Removed]

2: UI_CommonUIレベルを開きます。

3: 最奥のEnhancedInputのサンプルで、BP_EventDemoTrigger7の**「Lock Input to UI」をFalse**にします。

[Image Removed]

4: ここまでで、以前ご教示いただいたとおり、このサンプルの「AW_EnhancedInputBottomPopup」画面でFaceButtonTopがちゃんと効きます。

[Image Removed]

今度はこの**「SpawnCenterPopup」ボタンをHoldでトリガーするようにしたい**です。

【試したこと】

「AW_EnhancedInputBottomPopup」の「SpawnCenterPopup」の詳細ビューで、「Requires Hold」をTrueにし、「Hold Data」を適当に作成しました。

[Image Removed]

「IA_UI_SpecificWidgetAction」の「Triggers」に「Hold」を追加しました。

[Image Removed]

「IMC_UI_Specific」の「IA_UI_SpecificWidgetAction」でも、「Triggers」に「Hold」を追加しました。

[Image Removed]

「UI_SpecificMetadataIMC」の**「Is Generic Input Action」をFalse**にしました。(Trueでも試しました。)

[Image Removed]

「AW_EnhancedInputBottomPopup」のEventGraphで、「SpawnCenterPopup」ボタンのClickイベントでも反応するように、↓のように繋げました。

[Image Removed]

ここまでやってみましたが、「AW_EnhancedInputBottomPopup」画面で**「SpawnCenterPopup」ボタンはHold(FaceButtonTop長押し)で反応しませんでした**。しかし、Button内のInputActionWidgetのProgressのBrushは表示されました。(Materialが未設定なので動きはしませんが。)

[Image Removed]

こちら、何か設定や手順に不備などございますでしょうか?

ご教示よろしくお願いします。

コードを見てて、気になる箇所がありました。

UActionRouteType.cpp の FActionRouterBindingCollection::ProcessHoldInput() では、Binding->HoldMappings がある場合にのみHoldの処理をしているように見受けられます。

EProcessHoldActionResult FActionRouterBindingCollection::ProcessHoldInput(ECommonInputMode ActiveInputMode, FKey Key, EInputEvent InputEvent, int32 UserIndex) const
{
	for (FUIActionBindingHandle BindingHandle : ActionBindings)
	{
		if (TSharedPtr<FUIActionBinding> Binding = FUIActionBinding::FindBinding(BindingHandle))
		{
			if (Binding->UserIndex == UserIndex && (ActiveInputMode == ECommonInputMode::All || ActiveInputMode == Binding->InputMode))
			{
				for (const FUIActionKeyMapping& HoldMapping : Binding->HoldMappings)
				{
					EProcessHoldActionResult ProcessResult = EProcessHoldActionResult::Unhandled;

しかし、同じcppの FUIActionBinding::FUIActionBinding() では、EnhancedInputモードのときは、HoldMappingsにAddする処理をしていません。

const auto RegisterKeyMappingFunc = 
		[this](const FUIActionKeyMapping& KeyMapping)
		{
			if (KeyMapping.Key.IsValid())
			{
				if (KeyMapping.HoldTime > 0.f)
				{
					HoldMappings.Add(KeyMapping);
				}
				else
				{
					NormalMappings.Add(KeyMapping);
				}
			}
		};
 
	if (BindArgs.ActionTag.IsValid())
	{
		const FUIInputAction* ActionMapping = UCommonUIInputSettings::Get().FindAction(BindArgs.ActionTag);
		check(ActionMapping);
		
		if (ActionDisplayName.IsEmpty())
		{
			ActionDisplayName = ActionMapping->DefaultDisplayName;
		}
 
		for (const FUIActionKeyMapping& KeyMapping : ActionMapping->KeyMappings)
		{
			RegisterKeyMappingFunc(KeyMapping);
		}
	}
	else if (CommonUI::IsEnhancedInputSupportEnabled() && BindArgs.InputAction.IsValid())
	{
		if (ActionDisplayName.IsEmpty())
		{
			ActionDisplayName = BindArgs.InputAction->ActionDescription;
		}
 
		// Nothing else to do if we have an enhanced input action,
		// the input action itself will be queried against for keys later
	}

コメントには↓のようにありますが、

  • // Nothing else to do if we have an enhanced input action, the input action itself will be queried against for keys later

EnhancedInputモードのときは、FActionRouterBindingCollection::ProcessHoldInput()内のHold処理に相当する処理を、別のところでやっていたりするのでしょうか?

お世話になっております。

本件、回答に時間を要しておりまして、誠に申し訳ございません。

現在、社内で意図した設定方法や、現在の実装状況の確認を行っております。

追加でご質問いただいた件も含め、いましばらくお時間を頂戴できますと幸いです。

引き続き、よろしくお願いいたします。

お世話になっております。

本件、確認に時間を要してしまい申し訳ありませんでした。

結論から申し上げますと、この Requires Hold プロパティは旧Input Systemのために作成されたもので、Enhanced Input Supportを有効にした際には機能いたしません。

コミュニティでも同様の指摘が行われているのを見つけましたので、参考までに共有いたします。

Enhanced Input Supportは現在のところ、単発押し(Click)のみ対応しており、それ以上の複雑な操作には対応していないとのことでした。

従いまして、

> EnhancedInputモードのときは、FActionRouterBindingCollection::ProcessHoldInput()内のHold処理に相当する処理を、別のところでやっていたりするのでしょうか?

という質問に関しましては、大変残念ながら、「処理は別のところに書かれているわけではなく、単に存在しない」という回答となります。。

弊社内製チームのあいだでは既知の制限とのことで、Hold操作が必要な場合は、UMG内で​ Enhanced Input の Hold イベントを直接リッスンして実装しているとのことでした。

以上、よろしくお願いいたします。​

ご確認いただきありがとうございます!

また、関連スレッドのご共有もありがとうございます。

現状では未対応項目ということ、承知しました。

Hold操作が必要な箇所は、ご教示いただいた方法で対処しようと思います。

ありがとうございました。

ご確認ありがとうございます。

それでは本件は回答済みとしてCloseさせていただきます。

またなにかございましたら、お気軽にEPSをご利用ください。

以上、よろしくお願いいたします。​