T.Saitou
(T.Saitou)
November 30, 2021, 5:48am
1
Hi, all. Currently I am trying to get the changed value with the following method.
PostEditChangeProperty( FPropertyChangedEvent& PropertyChangedEvent )
This is called as an event trigger when a parameter changes in the editor.
I can extract the changed variable name and type from that argument, but I don’t know how to retrieve its value.
I want to extract the vector3f type value to FVector3f.
If anyone knows, would you tell me how to do it ?
Sadly my computer literally died yesterday so my response will be limited. The below sets an object rotation, location, scale based on UPROPERTY() members which are being edited. It gets the value of the UPROPERTY and sets something else based on it. But set/get may exist for your specific case. (for the record I am typing in the dark with my laptop)
#if WITH_EDITOR
bool AMyCharacter::LeftPropertyName(FName PropertyName)
{
if (PropertyName == GET_MEMBER_NAME_CHECKED(AMyCharacter, LeftRotation)) return true;
if (PropertName == GET_MEMBER_NAME_CHECKED(AMyCharacter, LeftLocation)) return true;
if (PropertyName == GET_MEMBER_NAME_CHECKED(AMyCharacter, LeftScale)) return true;
return false;
}
void AMyCharacter::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
FName MemberPropertyName = (PropertyChangedEvent.MemberProperty != nullptr) ? PropertyChangedEvent.MemberProperty->GetFName() : NAME_None;
FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
if (LeftProperty(MemberPropertyName))
{
LeftObject->SetRelativeRotation(LeftRotation);
LeftObject->SetRelativeLocation(LeftLocation);
LeftObject->SetRelativeScale3D(LeftScale);
}
}
#endif
1 Like
If you’re recieving PostEditChange
on a UObject then the C++ variable corresponding to the property will have its new value.
So:
UCLASS()
class UMyClass : public UObject
{
GENERATED_BODY();
public:
UPROPERTY(EditAnywhere)
int32 Foo = 0;
// ...
};
//...
void UMyClass::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
if (PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UMyClass, Foo))
{
int32 NewVal = Foo; // <- Foo has changed
}
}
}
1 Like
T.Saitou
(T.Saitou)
December 1, 2021, 1:10am
4
Thank you for answering in a difficult situation, .
I’m glad this question wasn’t ignored.
I am learning with reference to your answer.
1 Like
T.Saitou
(T.Saitou)
December 1, 2021, 1:22am
5
Thak you for your responce, alistairwick.
It’s one of the answers I wanted.
I have updated the value that way, but I felt stupid myself by not using the argument of PostEditChangeProperty().
I thought the arguments contained both the updated variable name and the value.
Just thought only I couldn’t find a way to get it.
If I Interpret this feature is given as just a notification, everything I was worried about is solved.
Really thank you.
1 Like