RedditPP Mascot

RedditPP

r/unrealengine • … • u/NottingHillNapolean

Store Delegates in a Container, Return Delegates in Functions

In UE5.2, I'm trying to write publish/subscribe message subsystem. Ideally, I would have a `TMap<FString, MyDynamicMulticastDelegateType>` as a variable, with a function that maps FStrings to dynamic, multicast delegates.

To publish, I'd have a function:

`void Publish(FString message)`

that would look up the delegate corresponding to `message` and call `Broadcast`

&#x200B;

There would be another function:

`void Subscribe(FString message, MyDynamicMulticastDelegate& delegate)`

that would look up the delegate corresponding to `message`, creating one if necessary, and return it as `delegate`. Then, you could bind to that delegate.

I expect the `Publish` and `Subscribe` functions to be called from blueprints.

Is such a thing possible? The compiler says my delegate "is not supported by blueprint"

&#x200B;

— 0