Templated Blueprint functions

Unfortunately, templated function support is pretty limited at the moment. We’re looking to fix this up in the next few months, and make a generic solution for wildcard parameters, but for now, they have to be handled at the node level. We have support for a wildcard pin type (UEdGraphSchema::PC_Wildcard), which we currently use to get template-like functionality for array functions. You can see how we implement it in UK2Node_CallArrayFunction. The gist is that when you connect something to a wildcard slot, we propagate that type to the rest of the wildcard dependent pins. Under the hood, we pass-by-reference, and use the CustomThunk keyword in order to write our own thunk-layer and read the pointer off the stack and coerce the type.

You could do something similar, but much less invasive, if you made your own subclass of UK2Node_CallFunction, and then allocated a wildcard parameter. Then, in NotifyPinConnectionListChanged(), if the pin that was connected was a wildcard, you could search for an appropriate UFunction for your type, and then call UK2Node_SetFromFunction. That’s not purely templated, but would allow you get a similar effect!

1 Like