Hi I have a quick question about C++ class constructors for UCLASS classes. Is the default constructor (AActor::Actor(const FObjectInitializer& ObjectInitializer)) called whenever an object is modified in the editor like a blueprint construction script?
I’m trying to dynamically create level walls on a spline but the constructor doesn’t seem to run when the spline is edited or the object moved.
If it doesn’t work like this is there a function that is called whenever the object is modified in the editor? I’ve tried AActor::OnConstruction(const FTransform &Transform) as well.
I’ve successfully used PostEditChangeProperty for this in the past:
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
void AMyActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
auto name = PropertyChangedEvent.Property->GetNameCPP();
if (name == TEXT("MyPropertyName"))
Thanks, I guess doing it this way will ultimately be more efficient than running construction code everytime you do something the way blueprints do, my blueprint prototype was very slow as it tried to refresh everytime I moved it a little bit. Do you know if it’s possible to make a function run when an actors component is modified? It seems that PostEditChangeProperty dosen’t run when you modify the spline component.
Have you found a way to make a function run when a component is modified? As you stated, PostEditChangeProperty is only called when the actor itself is modified. I could probably create a custom spline component class that overrides the PostEditChangeProperty function but I’m sure there’s an easier way. I mean if the blueprint calls the construction script every time an actor or one of its components is modified, there must be a way to do something similar in c++, right?
Components also have a PostEditChangeProperty. You may try it.