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?