For those coming to this later and not skilled in c++. This is my solution. Create an actor, add it to the scene and assign a landscape which you want to spawn immediately.
You also NEED to add Landscape to your project.Build.cs file, otherwise it will fail to find proper libraries.
YourProject.build.cs
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Landscape"});)
LFLandscapeGrassHack.h
#pragma once
#include "CoreMinimal.h"
#include "LandscapeProxy.h"
#include "GameFramework/Actor.h"
#include "LandscapeGrassHack.generated.h"
UCLASS()
class YOURPROJECT_API ALandscapeGrassHack : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALandscapeGrassHack();
UPROPERTY()
USceneComponent* Root;
UPROPERTY(EditAnywhere)
ALandscapeProxy* Landscape;
protected:
virtual void BeginPlay() override;
void UpdateGrass(ALandscapeProxy* LandscapeToUpdate);
};
LandscapeGrassHack.cpp
#include "LandscapeGrassHack.h"
ALandscapeGrassHack::ALandscapeGrassHack()
{
PrimaryActorTick.bCanEverTick = false;
Root = CreateDefaultSubobject<USceneComponent>("Root");
RootComponent = Root;
}
void ALandscapeGrassHack::BeginPlay()
{
Super::BeginPlay();
UpdateGrass(Landscape);
}
void ALandscapeGrassHack::UpdateGrass(ALandscapeProxy* LandscapeToUpdate)
{
if(!IsValid(LandscapeToUpdate))
{
UE_LOG(LogTemp, Warning, TEXT("NO landscape has been assigned, cannot recreate grass"));
return;
}
FOccluderVertexArray arr;
LandscapeToUpdate->UpdateGrass(arr, true);
}