- 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:
- 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.
- In your Source folder, create a new folder using the same name as you specified in your uproject file (in this instance, "Chapter_10Editor"):
- 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" } );
}
}
- Inside this new folder, create a blank .txt file and rename it to Chapter_10Editor.Build.cs:
- 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" });
}
}
- 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
{
};
- Lastly, create a new source file called Chapter_10Editor.cpp.
- Add the following code:
#include "Chapter_10Editor.h"
#include "Modules/ModuleManager.h"
#include "Modules/ModuleInterface.h"
IMPLEMENT_GAME_MODULE(FChapter_10EditorModule, Chapter_10Editor)
- Finally, close Visual Studio if you have it open. Then, right-click on the .uproject file and select Generate Visual Studio Project files:
- You should see a small window launch, display a progress bar, and then close:
- You can now launch Visual Studio, verify that your new module is visible in the IDE, and compile your project successfully:
- 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.