Well I found a solution (the upvoted answer is 5 years old and does not work anymore).
UPROPERTY(Category = "Camera", BlueprintReadWrite, EditAnywhere)
TSubclassOf<UCameraComponent> CameraComponentType;
UPROPERTY(Category = "Camera", BlueprintReadOnly)
UCameraComponent * CameraComponent;
ACustomPawn::ACustomPawn(): Super()
{
// Get the object as modified in editor
ACustomPawn* DefaultObject = Cast<ACustomPawn>(this->GetClass()->GetDefaultObject());
// Get value of sub class to use
TSubclassOf<UCameraComponent> DefaultClass = DefaultObject->CameraComponentType;
if (DefaultClass)
{
CameraComponent = Cast<UCameraComponent>(this->CreateDefaultSubobject(TEXT("Camera"), UCameraComponent::StaticClass(), *DefaultClass, true, false, false));
}
}
I’m not sure it’s the simplest, but at least it works (been looking for it for 15 hours).