All Properties of C++ generated Components (except the root) are reset when playing/loading scene

I have a simple actor class, containing two BoxComponents

UCLASS()
class MYPROJECT3_API AMyTrigger : public AActor
{
	GENERATED_BODY()
public:	
	AMyTrigger();
};

Cpp File:

// Sets default values
AMyTrigger::AMyTrigger()
{
    UBoxComponent* boxTriggerComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("Box-Trigger A"));
    boxTriggerComponent->SetBoxExtent(FVector(100.f, 100.f, 100.f));
    boxTriggerComponent->SetRelativeLocation(FVector(0, 0, boxTriggerComponent->GetScaledBoxExtent().Z * 0.5f));
    RootComponent = boxTriggerComponent;
    
    boxTriggerComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("Box-Trigger B"));
    boxTriggerComponent->SetBoxExtent(FVector(100.f, 100.f, 100.f));
    boxTriggerComponent->SetRelativeLocation(FVector(0, 0, boxTriggerComponent->GetScaledBoxExtent().Z * 0.5f));
    boxTriggerComponent->AttachTo(RootComponent);
}

When I change a property of the root component (for example change the Box Extend), save the scene and reopen it, the change gets stored.

That’s not the case fot the case for the second component. When I change the same property of the second component, and reload the scene, the box extend gets reset to he default value.

Is there a workaround I can use to allow editing and storing the values of components different to the root component?

Ok, I’ve tried the Preview 3 of 4.8, there the component properties I can’t changed are already greyed out automatically. So this ticket can be treated as fixed.

In order not to into the same Problems as I did, just use 4.8 or newer. The editor event told me exactly what to do! Great Job! :slight_smile:

If you want your components to be editable, all you have to do is to provide a UProperty pointer point to that component with EditAnywhere

UCLASS()
class MYPROJECT3_API AMyTrigger : public AActor
{
	GENERATED_BODY()
public:	
	AMyTrigger();

    UPROPERTY(EditAnywhere) // <------------------------------------------------- NEW
    UBoxComponent* a; // <------------------------------------------------------- NEW
    UPROPERTY(EditAnywhere) // <------------------------------------------------- NEW
    UBoxComponent* b; // <------------------------------------------------------- NEW
};

Cpp File:

// Sets default values
AMyTrigger::AMyTrigger()
{
    UBoxComponent* boxTriggerComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("Box-Trigger A"));
    boxTriggerComponent->SetBoxExtent(FVector(100.f, 100.f, 100.f));
    boxTriggerComponent->SetRelativeLocation(FVector(0, 0, boxTriggerComponent->GetScaledBoxExtent().Z * 0.5f));
    RootComponent = boxTriggerComponent;
    a = boxTriggerComponent; // <------------------------------------------------- NEW
    
    boxTriggerComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("Box-Trigger B"));
    boxTriggerComponent->SetBoxExtent(FVector(100.f, 100.f, 100.f));
    boxTriggerComponent->SetRelativeLocation(FVector(0, 0, boxTriggerComponent->GetScaledBoxExtent().Z * 0.5f));
    boxTriggerComponent->AttachTo(RootComponent);
    b = boxTriggerComponent; // <------------------------------------------------- NEW
}