Hello
First time doing a plugin and trying to spawn an empty Landscape using the code below.
But my method of spawning the Landscape is not compiling giving: error LNK2019: unresolved external symbol
Any suggestions on what might be wrong?
UWorld* World = nullptr;
// We want to create the landscape in the landscape editor mode's world
FWorldContext& EditorWorldContext = GEditor->GetEditorWorldContext();
World = EditorWorldContext.World();
ALandscape* Landscape = World->SpawnActor<ALandscape>(FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, 0.0f, 0.0f));
I had not included it, but adding it did not help.
But maybe I did it wrong, seems that I’m lacking som understanding of this.
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Projects",
"InputCore",
"EditorFramework",
"UnrealEd",
"ToolMenus",
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"Landscape", //I added this, is it correct?
// ... add private dependencies that you statically link with here ...
}
);
Yes you added it correctly. And it compiles for me (when putting your code above into an actor), so I’m not sure what could be wrong. I created a new blank c++ project, then a new blank plugin. Then I added an actor to that plugin and inside the .cpp file of the actor included
#include "Landscape.h"
#include "Editor.h"
and in the BeginPlay added
UWorld* World = nullptr;
// We want to create the landscape in the landscape editor mode's world
FWorldContext& EditorWorldContext = GEditor->GetEditorWorldContext();
World = EditorWorldContext.World();
ALandscape* Landscape = World->SpawnActor<ALandscape>(FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, 0.0f, 0.0f));
And I added “Landscape” and “UnrealEd” to the PrivateDependencyModuleNames of the Build.cs file of the plugin, now it looks like
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"Landscape",
"UnrealEd"
// ... add private dependencies that you statically link with here ...
}
);