Just needed to do this, worked it out by following the code in GetDataTableRowFromName and SetStructurePropertyByName blueprint nodes, this has general purpose struct passing (out in this case, but it’s easy to switch it to in by setting the struct parameter to const, the mechanism is the same). You need to do the following:
Declare a UFUNCTION as you would for a normal blueprint function.
Add the “CustomThunk” attribute, and (in the “meta” section) add a CustomStructureParam that refers to your parameter.
The parameter should be of type FGenericStruct& (and const for input, non-const for output)
You also need a (static) function that has almost the same signature except void* for the type, these are named Generic_* by Unreal convention.
You need to declare a custom thunk implementation of exec[YourFunctionName] using the DECLARE_FUNCTION macro and a series of P_GET_OBJECT/PROPERTY/etc/P_FINISH/P_NATIVE_BEGIN/P_NATIVE_END (and RESULT_PARAM if you have a return value).
For the generic structure passing you use Stack.StepCompiledIn(NULL); and void* SrcStructAddr = Stack.MostRecentPropertyAddress; together to produce a pointer to the data structure in memory that is passed in.
This can then be used as the void* parameter to pass to the Generic_* function where the struct is referred to.
This gets you a void* but that’s not that useful unless you have also passed in some more information about the structure, e.g. a UScriptStruct or UStruct pointer perhaps. (my use case was UUserDefinedStruct).
With this extra information you can do things like:
Get a pointer to the first field definition of the struct: FField* prop = pstruct_type->ChildProperties;
loop through them using while(prop) { … prop = prop->Next; }
Check for the types you are interested in handling by casting to the various FProperty types, e.g. FNumericProperty num_prop = CastField(prop);
Make a pointer to the field within the struct memory image: const uint8* pdata = (uint8*)in_struct_instance_ptr + num_prop->GetOffset_ForUFunction();
Set/Get it’s value (in this case I want integer numerics): if (num_prop->IsInteger()) {
int value = (int)num_prop->GetSignedIntPropertyValue(pdata); //do something with value… }
Hope that is enough to get anyone still reading this started.