CustomThunk ("Templates" in Blueprints)
In C++, templates can be used to write generic code for functions that can be used with different data types:
// Template to convert any enum type to a string
template <typename TEnumType>
static FString EnumToString(const TEnumType EnumValue)
{
const UEnum* EnumPtr = StaticEnum<TEnumType>();
if (!EnumPtr)
{
return NSLOCTEXT("Invalid", "Invalid", "Invalid").ToString();
}
return EnumPtr->GetNameStringByIndex(static_cast<int32>(EnumValue));
}While there is no direct equivalent of template programming in Blueprints, there is a UFUNCTION reflection specifier "CustomThunk" that will allow us to create functions with generic parameters.
The syntax
Last updated