I’m trying to make a generic struct to string map node, and met a strange problem.
when I using FProperty->GetPropertyValue(), It got all wrong similar value.
and when I using FProperty->ContainerPtrToValuePtr(), It got all right value.
why?
I’m trying to make a generic struct to string map node, and met a strange problem.
why?
Despite the apparent similarity in name, FProperty::GetPropertyValue doesn’t perform as expected. Internally, it simply invokes:
/** Convert the address of a value of the property to the proper type */
static FORCEINLINE TCppType const* GetPropertyValuePtr(void const* A)
{
return (TCppType const*)A;
}
This snippet essentially takes your ValuePtr pointer and converts it to the specified type (in your case, float). However, if ValuePtr is a struct and you attempt to convert it to a float (when it’s not), it retrieves the first member variable in the struct’s layout, resulting in a consistent return value regardless of input. This function truly needs either a clearer name or more detailed documentation.
Moving on to FProperty::ContainerPtrToValuePtr, it indeed accomplishes the intended task of extracting the property from the struct. Internally, it conducts a simple struct member pointer offset operation, resembling something like return (uint8*)ValuePtr + MemberVariableOffset;
Thanks for your replay. The func name has indeed caused me trouble.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.