Is it possible to create a Blueprint implementable event in UBlueprintFunctionLibrary?

Is it possible to declare a BlueprintImplementable event inside a UBlueprintFunctionLibrary-derived class? It looks like the library functionality requires member functions to be static in order for them to be visible in the graph editor, but the BlueprintImplementable tag wants the function to be an instance function. I’m looking at exposing a hardware integration as a series of input events in a UBlueprintFunctionLibrary within a plugin, so any advice regarding this would be helpful.

#Multiple BP Inheritance

I cant think of any way to do this as a plugin without Epic creating multiple BP inheritance.

Will make a post about that…

1 Like

Did you ever come with a solution or idea for this? I am having the same issue. I want the event to be visible in Blueprint without having to instantiate anything, similar to the way that you want. My posts: BlueprintImplementableEvent function in a UBlueprintFunctionLibrary derived class? - C++ - Unreal Engine Forums and How to broadcast delegates from static functions? And how to singletons/managers? - C++ - Unreal Engine Forums?

What I ended up doing was implement an ActorComponent that could be added to anything that needed to ‘listen in’ for events. That ActorComponent contains some delegates, which then show up as events you can add to blueprints containing an instance of that component. ApplicationLifeCycleComponent is an example of how to do this, if I recall correctly.

Hi twiddle. Would you mind posting an answer to your question explaining in a little more detail how you were able to achieve what you were trying to do? There may be others trying to accomplish something similar who would benefit from knowing what you did. Thanks.

Have a great day!

My solution wasn’t really a direct solution so much as it took a different approach. I created a custom module, and in the StartupModule() function I set up a set of static delegates inside a UObject-derived class (so I am sort of technically instantiating something). I then created an ActorComponent subclass, which uses OnRegister and OnUnregister to ‘listen in’ to those delegates by binding functions on the ActorComponent to them.

The instance functions that were bound, in turn broadcast to multicast delegates declared as instance variables on the actorComponent. If those are marked as UPROPERTY() you can add events for the component in the component view in blueprint, and those events can then be added to your event graph.

This means that any actor that wants to be notified of the events at hand simply adds an instance of the Component, and can then use the Blueprint nodes to implement their event handler.

This works quite well if you want to simply fire the event via a simple event node (like a custom event); if you want to have multiple pins corresponding to stop/start on your single event node, though, you’ll need to implement some K2Node subclasses and mess about with dynamic binding objects, which is what I did in order to have a cleaner blueprint-visible API (given that I’m dealing with gesture detection, it made more sense to have start and stop on a single node).

There’s a pull request on Github with my approach if you’would like to check it out in more detail; bear in mind that it is being reviewed at the moment and may not necessarily be the absolute best way to accomplish this just yet.

1 Like