How to do it...

  1. Open your project's .uproject file in a text editor such as Notepad or Notepad++. You can find the file inside your project folder, and it should look similar to what's shown in the following screenshot:

  1. Add the bold section of text in the following snippet to the file:
{
"FileVersion": 3,
"EngineAssociation": "4.21",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "Chapter_10",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "Chapter_10Editor",
"Type": "Editor",
"LoadingPhase": "PostEngineInit",
"AdditionalDependencies": [
"Engine",
"CoreUObject"
]
}
]
}

Note the comma after the first module before the second set of curly braces.

  1. In your Source folder, create a new folder using the same name as you specified in your uproject file (in this instance, "Chapter_10Editor"):

  1. Open up the Chapter_10Editor.Target.cs file and update it to the following:
using UnrealBuildTool;
using System.Collections.Generic;

public class Chapter_10EditorTarget : TargetRules
{
public Chapter_10EditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;

ExtraModuleNames.AddRange( new string[] { "Chapter_10Editor" } );
}
}
  1. Inside this new folder, create a blank .txt file and rename it to Chapter_10Editor.Build.cs:

  1. Insert the following into the file:
using UnrealBuildTool;

public class Chapter_10Editor : ModuleRules
{
public Chapter_10Editor(ReadOnlyTargetRules Target) :
base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string[] { "Core",
"CoreUObject", "Engine", "InputCore", "RHI", "RenderCore",
"ShaderCore", "MainFrame", "AssetTools", "AppFramework",
"PropertyEditor"});

PublicDependencyModuleNames.Add("Chapter_10");

PrivateDependencyModuleNames.AddRange(new string[] {
"UnrealEd", "Slate", "SlateCore", "EditorStyle",
"GraphEditor", "BlueprintGraph" });

}
}
  1. Still inside of the Chapter10_Editor folder, create a new file called Chapter_10Editor.h and add the following:
#pragma once

#include "Engine.h"
#include "Modules/ModuleInterface.h"
#include "Modules/ModuleManager.h"
#include "UnrealEd.h"


class FChapter_10EditorModule: public IModuleInterface
{
};
  1. Lastly, create a new source file called Chapter_10Editor.cpp.
  2. Add the following code:
#include "Chapter_10Editor.h" 
#include "Modules/ModuleManager.h"
#include "Modules/ModuleInterface.h"

IMPLEMENT_GAME_MODULE(FChapter_10EditorModule, Chapter_10Editor)
  1. Finally, close Visual Studio if you have it open. Then, right-click on the .uproject file and select Generate Visual Studio Project files:

  1. You should see a small window launch, display a progress bar, and then close:

  1. You can now launch Visual Studio, verify that your new module is visible in the IDE, and compile your project successfully:

  1. The module is now ready for the next set of recipes.
Code changes made in this editor module won't support hot-reloading in the same way that code in runtime modules does. If you get a compilation error that mentions changes to generated header files, simply close the editor and rebuild it from within your IDE instead.