What is the proper method for extending the Editor Engine?

Hi there

I have successfully extended the editor engine to our own version which compiles and works fine in the editor.

But I am having issues getting it to compile for the standalone build (development or debug).

Whats the intended work flow for extending the editor engine (and editor classes in general) for standalone builds.
I imagine the idea is to not include them, but how do I stop my class from being automatically picked up in that case?

I tried to use the WITH_EDITOR define, but it seems I have to keep some part of the class definition there and that requires knowing what UUnrealEdEngine is.

Here is the class definition:

UCLASS(transient)
class UOurEditorEngine : public UUnrealEdEngine

I also have the “UnrealEd” module in my PublicDependencyModuleNames

Has anyone succesfully include an extension to the editor engine and got the non editor build compiling?

You’re going to want to make a new module to build your editor specific code, so that it’s separate from your game code. Unfortunately we don’t seem to have an example/sample which does this, however I’ll try and walk you through it as best I can.

If you go to the Source folder for your project, you’ll notice you have two .Target.cs files; in my case I’m going to pretend your project is called “MyCodeProject” (replace as appropriate), so you’d see:

  • MyCodeProject.Target.cs
  • MyCodeProjectEditor.Target.cs

If you open up these files, you’ll notice that they both output a single module from SetupBinaries, what we’re going to do is add an extra module called “MyCodeProjectEditor” to contain your editor code.

Open MyCodeProject.Target.cs and in SetupBinaries add the following:

if (UEBuildConfiguration.bBuildEditor)
{
    OutExtraModuleNames.Add("MyCodeProjectEditor");
}

Open MyCodeProjectEditor.Target.cs and in SetupBinaries add the following:

OutExtraModuleNames.Add("MyCodeProjectEditor");

Now, inside your Source folder, create a new folder called “MyCodeProjectEditor”, and copy the following files from the “MyCodeProject” folder, into “MyCodeProjectEditor” folder:

  • MyCodeProject.Build.cs
  • MyCodeProject.h
  • MyCodeProject.cpp

Rename these files in the “MyCodeProjectEditor” folder so you see:

  • MyCodeProjectEditor.Build.cs
  • MyCodeProjectEditor.h
  • MyCodeProjectEditor.cpp

Open MyCodeProjectEditor.Build.cs and rename the class from “MyCodeProject” to “MyCodeProjectEditor”.

Open MyCodeProjectEditor.cpp, and fix the include name, and then change the macro which implements the module to be:

IMPLEMENT_GAME_MODULE( FDefaultGameModuleImpl, MyCodeProjectEditor );

Finally you need to update your .uproject file so that it knows about your new module, so open that up in some form of competent text editor (eg, Notepad++), and adjust the “Modules” section so that it contains your new editor module; when you’re finished, it would look something like this:

"Modules": [
	{
		"Name": "MyCodeProject",
		"Type": "Runtime",
		"LoadingPhase": "Default"
	},
	{
		"Name": "MyCodeProjectEditor",
		"Type": "Editor",
		"LoadingPhase": "Default"
	}
],

If you re-generate your projects and build, you should hopefully now have a separate editor module. You’ll be able to use this module to contain your editor specific code (move the editor dependencies into the MyCodeProjectEditor.Build.cs file, and move the editor specific code into that module folder).

You’ll probably also want to add “MyCodeProject” to the PublicDependencyModuleNames in your MyCodeProjectEditor.Build.cs file, as this will allow your editor module access to your game code.

Thanks for that Jamie, I will get that done today and let you know if I run into any issues.

Hi Jamie,

So I had a quick go at this doing but whilst I can compile non editor, the editor code fails.

It seems to be failing to link in the my normal games module:

Module.MyCodeProjectEditor.cpp.obj : error LNK2019: unresolved external symbol “public: static class UClass * __cdecl AMyCodeProjectActor::GetPrivateStaticClass(wchar_t const *)”

I added MyCodeProject to the PublicDependencyModuleNames in the MyCodeProjectEditor.Build.cs

I am currently still on an early version of UE4 so maybe there was something that changed also causing this. We are in the process of moving to the latest github version.

It does seem to be linking the MyCodeProject.dll first and that succeeds.

Okay, I’ll have a go at reproducing this locally.

Could you first try deleting/renaming the Intermediate folder for your project (you’ll need to re-generate your Visual Studio project files again after doing this), just to rule out any stale build files that might still be lurking around from when these two modules were combined.

Hi Ben, sorry for the delay, I had some issues getting UnrealVersionSelector working for my build.

I’ve managed to reproduce this locally, and I suspect you may have the same issue.

To link to a class from another module, it needs to have been exported via the API macro for that module; our new class wizard doesn’t add this, so you’ll need to add it to any public classes yourself. It will look something like this:

class MYCODEPROJECT_API AMyActor : public AActor

All in all, this has been a very useful question as it’s highlighted some flaws with our processes. I’m scheduled to make some improvements to the new class wizard, so I’ll make a note to ensure that the API macro is added to public classes by default; I’ve also raised a bug about making the process of adding a new module a lot easier.

I’ve also found that if you’re not using the Public/Private folder layout, then you can’t include your headers into another module (I assume you’re already using this layout since you only had linker errors). This is an issue that the core team is already looking at.

Adding the API made it compile here too, thank you very much!

https://docs.unrealengine.com/latest/INT/Programming/Modules/Gameplay/index.html badly needs updating with the information on this page.

But editor coding is quite diffrent from gameplay coding which module making for that is described in there. Editor extending needs separate documentation imo

Great Answer Jamie!!
As rhm suggested. Updating the documentation page might need an update regarding this matter.

Not sure why, but after adding this to my uproject file:

 {
     "Name": "MyCodeProjectEditor",
     "Type": "Editor",
     "LoadingPhase": "Default"
 }

I get this error when trying to generate new project files:

119576-untitled.png

Can’t tell what file needs to be unlocked :confused: Any ideas?

Hello rcdarcey. I just came across this post so you may of already fixed this issue. If you haven’t, you should be able to fix that by making sure that your .uproject file is not set to Read-Only

Hey rcdarcey, delete your unreal project intermediate folder and intermediate plugin folder (if exist), next step is re-generate project files of your unreal project.

So, 3 years later, has the option to automatically add new modules been implemented? Not that it’s particularly difficult to do by hand, but elegant solutions are always better!