I’m iterating through an object’s properties, storing them in a TArray<FString> by name and at the same time storing the associated value in a TArray<float>.
However, I’m getting this output using my UE_LOG feedback:
[2015.06.02-18.56.58:990][153]LogTemp:Warning: Getting float property from GravityMagnitudeDuringGlide, value is -107374176.000000:
[2015.06.02-18.56.58:990][153]LogTemp:Warning: Getting float property from GravityCap, value is -107374176.000000:
[2015.06.02-18.56.58:991][153]LogTemp:Warning: Getting float property from FlapHoldTimeUntilGlide, value is -107374176.000000:
[2015.06.02-18.56.58:999][153]LogTemp:Warning: Reading back property names from TArrays, Property:GravityMagnitudeDuringGlide, Value: -107374176.000000
[2015.06.02-18.56.58:999][153]LogTemp:Warning: Reading back property names from TArrays, Property:GravityCap, Value: -107374176.000000
[2015.06.02-18.56.58:999][153]LogTemp:Warning: Reading back property names from TArrays, Property:FlapHoldTimeUntilGlide, Value: -107374176.000000
So I know the TArray emplace is working fine, except the float looks like an uninitialized(?) value…
I tried it in the object initializer, postinitializer, I tried it using ThisLevel->bIsVisible as a condition inside the tick and it always returns the same values, so I’m guessing there’s something I’m missing here.
Anyway, this is my code:
void AtwinStickPawn::GetObjectPropertyFloatValuesAndNames( UObject* Object )
{
FString FObjectName = Object->GetName();
UE_LOG( LogTemp , Warning , TEXT( "Getting float properties from %s"), *FObjectName );
int ForLoopCounter = 0;
for (TFieldIterator<UFloatProperty> Property( Object->GetClass() ); Property; ++Property)
{
uint32 IndexPosition = ForLoopCounter;
uint32 SizeOfUint32 = sizeof( uint32 );
bool Result = ForLoopCounter <= MAXUINT32;
check( Result );
float VariableValue;
Property->GetFloatingPointPropertyValue( &VariableValue );
FString VariableName = Property->GetNameCPP();
ThisObjectFloatPropertyNames.Emplace(VariableName);
ThisObjectFloatValuesByIndex.Emplace( VariableValue );
UE_LOG( LogTemp , Warning , TEXT( "Getting float property from %s, value is %f:" ) , *VariableName, VariableValue );
ForLoopCounter++;
}
for (uint32 i = 0; i < ((uint32)ThisObjectFloatPropertyNames.Num()); i++)
{
UE_LOG( LogTemp , Warning , TEXT( "Reading back property names from TArrays, Property:%s, Value: %f" ) , *ThisObjectFloatPropertyNames* , ThisObjectFloatValuesByIndex*);
}
}
Thanks!