Hi all, I have a lot of questions about the workings of the reflection system.
How to get a wild structure instance from UStruct*?
As I understood UStruct* is a reference to a structure in the UnrealEngine memory model, but when using UStruct* with CustomThunk such a field accepts any structure as input.
UFUNCTION(
BlueprintCallable,
Category = "Item Creation",
CustomThunk,
meta = (
Keywords = "Convert Struct to Item",
CustomStructureParam = "ItemStruct"
))
UGameItem* CreateItem(UStruct* ItemStruct);
DECLARE_FUNCTION(execCreateItem)
{
Stack.Step(Stack.Object, nullptr);
FProperty* StructProperty = CastField<FProperty>(Stack.MostRecentProperty);
void* StructPtr = Stack.MostRecentPropertyAddress;
P_FINISH;
P_NATIVE_BEGIN;
*static_cast<UGameItem**>(RESULT_PARAM) = P_THIS->HandleStruct(StructProperty, StructPtr);
P_NATIVE_END
}
And a quick question: how can I simulate the work of CustomThunk so that I can use a function from C++ the same way as I use it from Blueprints?