Custom Widget Spawner
How to show something other than the standard option menu
Last updated
How to show something other than the standard option menu
Last updated
Note that the tools demonstrated in this page are accessible from MSquared v20
Experimental - Customers are encouraged to test and use this feature in their experiences, but it may still require some additional support
When using interactables, you may want to use the standard options menu available but in some cases you may wish to display your own custom widget (such as a visual representation for a vending machine). This page will detail how to create that, by walking you through our example object BP_Example_Interaction_WidgetSpawner
.
Below are the steps to re-create this example object.
Create an Actor you wish to have spawn a widget on interaction
Add the M2_Interactable component
Right click the interactable component -> Add event
-> InitializeInteract
If you require the standard interaction menu; Right click the interactable component -> Add event
-> OnButtonOptionRequested
.
Use InitializeInteract
to set ShowMenuOnInteract
on the interactable component. Then either open your custom widget or, if needed, dynamically adjust options ready for the standard interaction menu.
If using the standard interaction menu, handle option selected logic in OnButtonOptionRequested
.
It is very important that your widget call CompleteInteraction
upon closing, to allow the handler to accurately track it's interaction status.
If you wish your widget to listen to external sources requesting interactions be closed, bind to RequestCloseInteraction on the Interactable Handler.
Our example of this can be found in the Approachability and Feature Test Gyms, or directly via
/Plugins/M2Unreal/JunoSkypark/Content/ObjectInteraction/Examples/CustomWidgetSpawner