x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to use editor classes from within an actor class

I've added the following to the top of my HelloWorldPrinter.h file (which was created from this programming starter documentation project). The goal here is to auto create a new cube from code within the editor as a proof of concept.

 #include "UnrealEd.h"

I then have the following in my .cpp, which intellisense seems to agree with just fine. Which was borrowed from Unreal's own test code in the repo.

 UWorld* World = GEditor->LevelViewportClients[0]->GetWorld();
 UCubeBuilder* cubeBuilder = Cast<UCubeBuilder>(GEditor->FindBrushBuilder(UCubeBuilder::StaticClass()));
 cubeBuilder->X = 4096.0f;
 cubeBuilder->Y = 4096.0f;
 cubeBuilder->Z = 128.0f;
 cubeBuilder->Build(World);
 GEditor->Exec(World, TEXT("BRUSH MOVETO X=0 Y=0 Z=0"));
 GEditor->Exec(World, TEXT("BRUSH ADD"));

However, when I go to build I get the following error (yadayada = the long path to my project).

 yadayada.....lib and object yadayada.exp

 HelloWorldPrinter.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class UClass * __cdecl UCubeBuilder::GetPrivateStaticClass(wchar_t const *)" (__imp_?GetPrivateStaticClass@UCubeBuilder@@CAPEAVUClass@@PEB_W@Z) referenced in function "class UCubeBuilder * __cdecl Cast<class UCubeBuilder>(class UObject *)" (??$Cast@VUCubeBuilder@@@@YAPEAVUCubeBuilder@@PEAVUObject@@@Z)

 HelloWorldPrinter.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class UBrushBuilder * __cdecl UEditorEngine::FindBrushBuilder(class UClass *)" (__imp_?FindBrushBuilder@UEditorEngine@@QEAAPEAVUBrushBuilder@@PEAVUClass@@@Z) referenced in function "public: virtual void __cdecl AHelloWorldPrinter::BeginPlay(void)" (?BeginPlay@AHelloWorldPrinter@@UEAAXXZ)

 HelloWorldPrinter.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class UEditorEngine * GEditor" (__imp_?GEditor@@3PEAVUEditorEngine@@EA)

 yadayada.dll : fatal error LNK1120: 3 unresolved externals

Is there a better way to include the editor classes and have them resolved? Or am I doing something wrong.

Product Version: Not Selected
Tags:
more ▼

asked Apr 06 '14 at 08:31 AM in C++ Programming

avatar image

Nogbit
31 18 13 17

avatar image 王思宇 Apr 25 '15 at 02:44 AM

hello,Can you give me a complete code?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Are you linking to the UnrealEd module?

more ▼

answered Apr 06 '14 at 11:14 AM

avatar image

Jamie Dale STAFF
7.4k 176 66 304

avatar image Nogbit Apr 06 '14 at 05:22 PM

Probably not, how do I do that?

avatar image Jamie Dale STAFF Apr 06 '14 at 05:28 PM

In the .Build.cs file for whatever you're working on, they'll be a list of PrivateDependencyModuleNames and you'll likely just need to add "UnrealEd" to that list (alternatively it may need to go into PublicDependencyModuleNames depending on where/how you're using it).

For more information on UBT module dependencies, see: https://answers.unrealengine.com/questions/23384/what-is-the-difference-between-publicdependencymod.html

I'm curious about how you managed to include UnrealEd.h without that though, so perhaps you already have it.

avatar image Nogbit Apr 06 '14 at 05:52 PM

That worked! I was messing with build.cs at one point, but it wasn't in there just now, so maybe something got cached.

avatar image Ryan Darcey Dec 22 '16 at 03:18 AM

So, this fixes the compilation error building the editor, but then if you add UnrealEd to your build.cs file you get errors when compiling non-editor builds like "Development". is there another solution?

avatar image ImmutableLambda Jan 20 '17 at 05:39 PM

Can't use editor code outside editor builds. Best not to rely on that code during runtime. You can use

 #if WITH_EDITOR
 
 #endif // WITH_EDITOR

to wrap your editor only code so it doesn't try to compile, but if you gotta have it for your concept/feature/game to work, then best to move on to your own solution or to a different concept/feature/game.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question