Trash components in construction script

Hi,

I am trying to make an Actor with a SplineComponent that should add SplineMeshComponents dynamically after editing the spline in editor. But it results in TRASH objects all the time! Basically I have the same setup as in this three year old code. I tried with the root component mobility static and without:

.h:

	UPROPERTY()
		USplineComponent* WaySpline;

	/** Internal book keeping for the spline meshes we created along the spline */
	UPROPERTY()
		TArray<USplineMeshComponent*> SplineMeshComponents;

.cpp:

void ARoad::OnConstruction(const FTransform& Transform)
{
	Super::OnConstruction(Transform);

	// add missing nummber (just one normally as the construction script should run after each edit in editor)
	for (int32 NumToAdd = 0; NumToAdd < (WaySpline->GetNumberOfSplinePoints()-1 - SplineMeshComponents.Num()); NumToAdd++)
	{
		USplineMeshComponent* SplineMesh = NewObject<USplineMeshComponent>(this);

		SplineMesh->CreationMethod = EComponentCreationMethod::UserConstructionScript;
		SplineMesh->SetMobility(EComponentMobility::Static);
		SplineMesh->SetupAttachment(WaySpline);
		SplineMesh->SetStaticMesh(Mesh);

		SplineMesh->RegisterComponent();
		SplineMesh->UpdateRenderStateAndCollision();

		SplineMeshComponents.Add(SplineMesh);
	}
}

Adding two objects, they are first named _0 and _1. A second call to OnConstruct follows directly when dragging the actor in the viewport, it has trash objects named _1 and _2.

Am I missing s.th. here??? What is the correct way of adding Components in the construction script? Is it even possible?

Cheers

Found a solution!

EComponentCreationMethod::UserConstructionScript is actually not working as I anticipated. It seems that all UCS created components get killed before a new call to UCS.

But as my instanciation is protected from undesired bahaviour, I can of course do it in the UCS now with

EComponentCreationMethod::Instance

and the components stay instanced in editor.