Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can one use Delegate Functions within a UBlueprintFunctionLibrary?

I'm getting to grips with the Blueprint Function Library system, and I'm trying to allow for developers to bind Blueprint functions to events on the Blueprint Function Library I've created. I've seen this functionality supported in places throughout the engine such as the Functional Testing Manager, however I haven't quite worked out how to execute the events that I've defined.

For example, within the below code, I've created an 'ExampleAssignable' BlueprintAssignable property.

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FMyFunctionSignitureName, int32, Param1, int32, Param2, int32, Param3);
 class MY_PLUGIN_API UMyBlueprintFunctionCollection : public UBlueprintFunctionLibrary
             FMyFunctionSignitureName ExampleAssignable;

How can I trigger the ExampleAssignable event? Aside from calling ExampleAssignable.Broadcast() within a non-static member function, which I'm in turn also puzzled as to how I could call if it's not static, is there another valid way to do it? Is it possible perhaps to find a pointer to the Blueprint Function Library and access the property from within an external object?

Would love to hear any suggestions regarding best practices for this particular use case. Thanks!

Product Version: Not Selected
more ▼

asked Jan 18 '16 at 11:33 AM in C++ Programming

avatar image

Chris at Opaque
31 6 8 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Not sure what code you're referring to with the Functional Testing Manager, but this isn't possible with blueprint function libraries, since they cannot hold state. They are composed purely of static functions, so like you say there would be no way to access a non-static member. Likewise, the reflection system doesn't support static data member properties.

If you need state, you would have to derive from UObject rather than UBlueprintFunctionLibrary. But then to assign to the delegate, you'll need a reference to an object instance. Since static UFUNCTIONs are allowed on regular UObject classes, you could achieve this by making your class a singleton, and providing a UFUNCTION(BlueprintPure) static UMyObject* Get() which returned the singleton instance, from which you could bind to the delegate.

more ▼

answered Jan 18 '16 at 11:50 AM

avatar image

2.1k 83 37 121

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question