Hello, I’m trying to pass values through a class of UObject to do so I passe the class then retreive each property but after that I don’t know how to get it’s value.
I can get its name and type but not its value.
FProperty* prop = LastSample->GetClass()->FindPropertyByName(FName(* fieldName));
This gets the Property and its full name matches.
1 Like
Erdemacr
(Erdemacr)
April 28, 2022, 2:17pm
2
try this,
Value = prop->GetPropertyValue_InContainer(LastSample);
4 Likes
bierbrian
(bierbrian)
May 23, 2022, 12:58pm
4
That’s a function of TProperty how did you do it?
1 Like
@bierbrian It’s from FProperty, but you have to cast it. E.g. for a bool property you get the bool with:
if(Property->IsA(FBoolProperty::StaticClass())) {
const FBoolProperty* BoolProperty = static_cast<FBoolProperty*>(Property);
bool Value = BoolProperty - > GetPropertyValue_InContainer(Object);
// ...
}
All core types like float, double, int, … have such a helper function to get the value.
3 Likes
zos
(Andrew Tomazos)
October 1, 2022, 8:44pm
6
I think you might be able to write:
if (const FBoolProperty* BoolProperty = CastField<FBoolProperty>(Property)) {
instead (which does the IsA and cast and checks for null in one move, like dynamic_cast
) , but haven’t tested it sorry.
1 Like