The components show in the editor though, pseudocode :
ProceduralLandscape.h
UCLASS()
class ANATOLE_API AProceduralLandscape : public AActor
{
GENERATED_UCLASS_BODY()
// error persists when using GENERATED_BODY() without FObjectInitializer
UPROPERTY(VisibleAnywhere)
UGeneratedMeshComponent* meshComp;
//Tried Without VisibleAnywhere & with public access
//Changing this component to a common component like UCapsuleComponent doesn't help either
//Creating a UPROPERTY for the USphereComponent also doesn't help
}
ProceduralLandscape.cpp
AProceduralLandscape::AProceduralLandscape(const FObjectInitializer & objectInitialiser) : Super(objectInitialiser)
{
RootComponent = objectInitialiser.CreateDefaultSubobject<UCapsuleComponent>(this, FName("RootCapsule"));
meshComp = objectInitialiser.CreateDefaultSubobject<UGeneratedMeshComponent>(this, FName("GeneratedMesh1"));
ensure(RootComponent != nullptr); // never triggered
meshComp->AttachTo(RootComponent);
ensure(meshComp != nullptr); // never triggered
}
void AProceduralLandscape::someFunc()
{
ensure(meshComp != nullptr); // always triggers breakpoint.
}