Game Feature, adding functionality to a Widget BP

Hi there,

We are trying out the Modular Gameplay framework, which our project could benefit from. We are creating our first Game Feature plugin that will add a tool in our Game. Let’s say the tool is called ColorTool.

The ColorTool has it’s own modal Widget panel. The widget modifies the currently selected Actor ( present in the level ).

The ColorTool widget itself lives in the plugin.

Some logic for this tool gets added to the Actor via a Blueprint Component. That component lives in the plugin, and gets added to the actor by the plugin as an Action defined in the plugin’s data asset.

[Image Removed]

Now there is one last piece that is needed to make this work. The Color Tool Widget gets launched from a menu already existing in the main game. When the plugin isn’t loaded, that menu button ( let’s call it ColorToolButton ) does nothing. But when the plugin is active, ColorToolButton should launch the ColorTool widget.

We contemplated the idea of creating a BP component that we would add to the MenuBar. But we learned that Blueprint widgets don’t have BP components.

One way to go about this would be to have ColorToolButton emit an EventDispatcher. Then in the plugin, create an Actor called ColorToolSetup maybe, that finds the ColorToolButton, and listens to the click event, and launches the ColorTool widget.

Is there a more elegant way to do this tough, maybe using a dedicated Action in the Feature Plugin’s data asset? We liked the idea of adding functionality to the MenuBar directly, like an addon.

Your expert input would be greatly appreciated, thank you!

--- Update on 07/09 ----

We refactored the Menu Widget with a new function that creates the ColorTool Button, adds it to the menu, and defines a binding where the ColorTool launches when the button gets clicked.

It would be amazing if we could move this function into some kind of a component that would call it, say, On Construct, and the component would be added to the Menu Widget by the Feature Plugin. Not sure how to do that yet.

Steps to Reproduce
Blueprint Components can not be added to a Widget Blueprint in a Game Feature plugin via a “Add Component” action.

Hi there,

There is a good example of doing this within the Lyra Sample project.

It extends the available game feature actions with UGameFeatureAction_AddWidgets - Lyra\Source\LyraGame\GameFeatures\GameFeatureAction_AddWidget.h

It uses the UUIExtensionSubsystem to register a widget to match with a gameplay tag as a slot ID.

You might need to adjust the code slightly, as it references the Lyra HUD, but the Lyra HUD is primarily there for debugging purposes.

It also relies on a UIExtension plugin that comes with Lyra in the Lyra/Plugins directory- It allows extending UI elements in a modular way.

The lyra sample project is available free from FAB https://www.fab.com/listings/93faede1-4434-47c0-85f1-bf27c0820ad0

It adds a few new Game Feature Actions that might be of use while experimenting with this system.

If you need more information or assistance setting this up, let me know.

Kind Regards

Keegan Gibson

Hi Keegan,

Thank you for your answer! A new Game Feature Action type that adds a child widget to an existing widget at a given Named Slot seems like a perfect fit.

We will review the solution implemented in Lyra, and use it as a reference to try and implement a simple solution in our project.

Thank you so much for your suggestion!

Isabelle & team

I’m glad that was helpful.

I’ll close this support request for now. If you need anything else, please feel free to create a new support request.

Kind Regards

Keegan Gibson