I’ve made a new class deriving from AActor C++, which holds both, a static mesh component, and an instanced static mesh component:
protected:
UPROPERTY(VisibleAnywhere, Category="cat")
UStaticMeshComponent * sm;
UPROPERTY(VisibleAnywhere, Category="cat")
UInstancedStaticMeshComponent * ism;
They are initialized in the constructor as follows:
sm = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Locomotive"));
SetRootComponent(sm);
ism = CreateDefaultSubobject<UInstancedStaticMeshComponent>(TEXT("Wagons"));
ism->SetupAttachment(sm);
When I now try to create a blueprint of the Actor, I cannot add any instances to the instanced static mesh in blueprint editor, as the engine crashes with:
checkf(Stream.VertexBuffer->IsInitialized(), TEXT("Vertex buffer was not initialized! Stream %u, Stride %u, Name %s"), StreamIndex, Stream.Stride, *Stream.VertexBuffer->GetFriendlyName());
(in VertexFactory.cpp:184)
If I however add the instanced static mesh component via blueprint, everything works. I can also add instances to the instanced static mesh if it’s placed in a level instead of adding the instances in the blueprint editor.
Am I missing some initialization step for the instanced static mesh component?