Meshes of dynamically added components in editor mode not visible

I attempt to create and add components via C++ to an existing actor in editor mode. I have to do this while editing values and therefor i’ve overwritten the PostEditChangeProperty method. Since its not allowed to create components outside of the constructor using the CreateDefaultSubobject function i m using the ConstructObject function which do not crash. The components were added and shown in the Details panel of the actor but the StaticMeshComponent which is created inside my component is not shown.

I tried to create and attach my component inside the constructor of the actor and the StaticMeshComponent is visible (so the component itself is working fine). Are there any limitations in dynamically creating actors / components based on editor events (like PostEditChangeProperty)?

This is the code creating the components:

for (int x = 0; x < Width; x++)
	for (int z = 0; z < Height; z++)
		FString Name = TEXT("DebugTile_") + FString::FromInt(x) + TEXT("_") + FString::FromInt(z);
		UTileDebug* TileDebug = ConstructObject<UTileDebug>(UTileDebug::StaticClass(), this, FName(*Name));
		if (TileDebug)
			TileDebug->initialize(TileSize - 2.0f * TileDebugPadding, TileDebugPadding);
			TileDebug->SetVisibility(true, true);
			TileDebug->SetRelativeLocation(FVector(x * TileSize + TileSize * 0.5f, 0, z * TileSize + TileSize * 0.5f));

This is the code inside the component

TileMesh = CreateDefaultSubobject(TEXT(“TileDebugVisual”));
static ConstructorHelpers::FObjectFinder Box(TEXT("/Engine/BasicShapes/Cube"));
if (Box.Succeeded())

I had to write my custom UStaticMeshComponent and implement the OnRegister()-Method.

void MyClass::OnRegister()

Still had to register the new created component with the system using RegisterComponent(). Don’t know if the is the way it is supposed to be but it works. All static meshes dynamically created with my wrapper class are shown up in editor mode.

Hi I’m trying to do something similar to you and I have the same problem.

I have a class that inherits from static mesh component. Inside my character I have a TSubclassOf property that hold the type of component I want to use in my character. I create the component inside PostInitializeComponents. I can see that it has been created by using the specified class but it still won’t appear in the editor.

Do I have to do something special inside my SkeletalMesh class? Currently it overrides the OnRegister() function but I guess I need to do something else.

I know this is more than a year later… But did you end up getting this working? I’m trying to do the EXACT same thing.