rubm123
(rubm123)
April 9, 2022, 1:24am
1
I set up an event handler for the PostEditChangeProperty
. I use
const auto Name = PropertyChangedEvent.Property->GetFName();
to get the FName
of the affected property and I use
static const FName FNameSomeProp = GET_MEMBER_NAME_CHECKED(USplineComponent, SomeProp);
to then go on and check
if(Name = FNameSomeProp) // ...
So far so great. However, one of my properties is an FVector Velocity
. My variable Name
has the value “X”, “Y”, or “Z”, depending on which component I edit in the editor.
GET_MEMBER_NAME_CHECKED(USplineComponent, Velocity.X)
gives the more reasonable “Velocity.X”.
How do I go about it? Property
doesn’t seem to have a function that gives a fully qualified name. The GetFName
function gives a very incomplete name that won’t work anymore as soon as I add another FVector property.
For structs try PostEditChangeChainProperty .
Inside of the overridden function do something like:
#if WITH_EDITOR
void UYourAwesomeClass::PostEditChangeChainProperty(
FPropertyChangedChainEvent& PropertyChangedEvent)
{
Super::PostEditChangeChainProperty(PropertyChangedEvent);
const FName PropertyName = PropertyChangedEvent.GetPropertyName();
if (PropertyName == GET_MEMBER_NAME_CHECKED(UYourAwesomeClass, YourProperty))
{
}
}
#endif
1 Like
rubm123
(rubm123)
April 9, 2022, 3:45pm
3
You pointed me into the right direction. Some details, though:
PostEditChangeChainProperty is a generalized form; they always fire both
GetPropertyName
still only gives me X
, I need
const auto Name = PropertyChangedChainEvent.PropertyChain.GetHead()->GetValue()->GetFName();
… to get the FName
of my FVector property, and
const auto Tail = PropertyChangedChainEvent.PropertyChain.GetTail()->GetValue()->GetFName();
… to get the FName of members inside FVector (or any other struct).
For members that aren’t structs, Name
and Tail
are identical and give the simple property FName
None of this is documented. Luckily Rider has introspection.
2 Likes
I’ve never used GetHead or GetTail before, good to know how that works
I have seen that I can actually use this for structs
const FName PropertyName =
PropertyChangedEvent.PropertyChain.GetActiveMemberNode()->GetValue()->GetFName();
1 Like