I have a USTRUCT to define events on my actor. The user selects an event type via an enum in the struct, and then my hope is PostEditChangeProperty would assign the correct event struct to an FInstancedStruct, so I can easily populate with the params for whatever event is chosen.
The following code works as in there’s no crashes, and it appears I am getting a pointer to SOME instance of the struct, but not the one on the actor. If I call the SetEvent function on the struct member in the actor’s constructor it works, but calling it here does not.
Additionally I tried logging the value of the action enum and it prints the default value, not the value I change it to.
if (PropertyName == GET_MEMBER_NAME_CHECKED(FActionEvent, Action))
{
if (const FStructProperty* StructProperty = CastField<FStructProperty>(PropertyChangedEvent.MemberProperty))
{
void* StructAddress = StructProperty->ContainerPtrToValuePtr<void>(PropertyChangedEvent.MemberProperty->ContainerPtrToValuePtr<void>(this));
FActionEvent* ChangedStruct = static_cast<FActionEvent*>(StructAddress);
if (ChangedStruct != nullptr)
{
// The default for Action is "None". I changed it to "Debug" and it still prints "None".
LOG_ERROR("Action property: " + UEnum::GetValueAsString(ChangedStruct->Action))
// ??? Calling this function on the struct directly, works. This does not.
ChangedStruct->SetEvent<FEventDebug>();
}
}
}