I’m trying to figure out how to integrate my systems into blueprint. In native I have a custom event dispatching that leverages templates nicely to register to receive events of a certain type. I would like to be able to do this from blueprint directly as well instead of requiring boilerplate native that does event registration that routes to a blueprint.
This is what I have so far, a custom K2 node ‘Register for Event’. The primary inputs are the class type that represents the event type to be notified for and the delegate to call when that event happens.
What I would like to figure out is a way to update the delegate signature “B” based on changes to the event type “A”. The problem that I’ve ran into is in the configuration of delegate pins involve the referencing of a UFunction. Since the one of the points of the system is that the event system doesn’t know the concrete event types involved, I would prefer not to have to specify a bunch of unused functions.
I wouldn’t mind as much generating a bunch of unused delegate declarations (using the DECLARE_DELEGATE macros) however I was unable to determine how to get a UFunction reference from that as needed to configure a pin of type PC_Delegate.
I’m looking for any direction that may help. I’m open to alternative suggestions that would get me to my goal provided they meet the functionality requirements I’m trying to reach.
If you can get an FMulticastDelegateProperty or FDelegateProperty from wherever you’re getting your list of event types, which I assume is a UClass of some kind, you can then get the SignatureFunction from that.
i tried with code below which created the pin but when connected said it was the wrong direction. Also how did you add the signature? im still stumbling through the dark with K2Nodes
Per the comment on PC_Delegate, you set the SubCategoryObject to a UFunction pointer.
@DTG_DaveW No you can’t. That would require every class to manually declare a bunch of functions or delegate properties to create the variations with that specific class type. Which is just pointless boilerplate. Ultimately I wrote this as a custom node that combined the two nodes from the original post into a single node with a drop down so that I could do the type validation instead of relying on the delegate pin.
Generally, you would use a UClass* to the class with the function you want and you’d call FindFunction or FindFunctionChecked. You can also call the same functions on any UObject* add it will delegate to whatever class the UObject instance is.
ive created OutDelegates fine but i don’t think you can add a Signature to those, so i want the option to switch it to an InDelegate but when i connect it to an event it says pin is wrong direction or something.