Passing a non-default UPROPERTY to an Actor's component variable at construction time

To hide some implementation details in my actors and ease the designer’s workload, I intend to not show some C++ ActorComponents in the editor while still allowing some of their properties to be set. I do this by defining a smaller subset of these component properties directly as the Actor’s UPROPERTYies. At some point I obviously then need to pass these Actor UPROPERTYies to the Component.

Using the constructor doesn’t work, because it will set the variables before any BP-modified UPROPERTY values are applied:



AActor::AActor() :
    test(1), {
    component = CreateDefaultSubobject<UComponent>("component");

    component->test = test;
}


If I change “test” to 2 in the editor (in the BP archetype, or a spawned instance), component->test remains 1 both in the editor and PIE.

Using PostInitializeComponents() partially works:



AActor::AActor() :
    test(1), {
    component = CreateDefaultSubobject<UComponent>("component");
}

void AActor::PostInitializeComponents() {
    Super::PostInitializeComponents();

    component->test = test;
}


This correctly passes the property in PIE, but not in the editor (the component’s property remains the component’s default).

What should I use to make sure that each time the property changes in BP, the value is passed to the component? Is it possible at all?

I have used ‘PostEditChangeProperty’ before, but you need to wrap it in WITH_EDITOR tags. This is used for if you place a blueprint of an actor in the scene, then change a property, you will see the effects change in the editor. It depends on what your end goal is with the changing of these values?

To be fair, I’m not changing anything in the scene and only need these values to be set correctly ingame. I was mainly wondering if there was a better method of doing this with UE’s actor lifecycle.

BlueprintSetter = functionName

Google how to use custom bp setters.

Setters don’t seem to trigger when the value is modified through the editor’s interface though.