How to Rename an Unreal Engine Module
Updated: 1 day ago
Introduction
I was making a plugin for player interaction. I then wanted to clean it up and use modules and have a few frameworks for interaction such as a line trace interaction and a focused interaction - like new resident evil games. I wanted to rename the generated module name (same name as the plugin) to a specific interaction framework.
I'm writing this because I didn't find it easy, and the Rename action in Rider didn't do anything.
In this case, I was renaming a module from ContextualInteraction to FocusedInteraction.
Before you start
Close Unreal Editor.
Close Visual Studio/Rider.
Make sure your changes are committed or otherwise backed up.
Rename the module folder
For a plugin:
Plugins/
└── YourPlugin/
└── Source/
└── ContextualInteraction/
becomes:
Plugins/
└── YourPlugin/
└── Source/
└── FocusedInteraction/
Rename the Build.cs
inside the module folder, rename the .Build.cs file.
ContextualInteraction.Build.cs -> FocusedInteraction.Build.csThen rename the class and function inside of the file.
public class ContextualInteraction: ModuleRules
{
public ContextualInteraction(ReadOnlyTargetRules Target) : base(Target)To
public class FocusedInteraction : ModuleRules
{
public FocusedInteraction(ReadOnlyTargetRules Target) : base(Target)Update the module implementation
Rename the modules .h file
ContextualInteraction.h -> FocusedInteraction.h
ContextualInteraction.cpp -> FocusedInteraction.cppRename the class name
class FContextualInteractionModule : public IModuleInterfaceto
class FFocusedInteractionModule : public IModuleInterfaceRename everything in the .cpp file, including the IMPLEMENT_MODULE
IMPLEMENT_MODULE(FFocusedInteractionModule, FocusedInteraction)Update the .uproject / .uplugin
Open the .uproject or .uplugin and update the "modules"
"Modules": [
{
"Name": "FocusedInteraction",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "InteractionCore",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],Update dependencies
Search the entire project for:
ContextualInteractionand update references - e.g. check dependency references in other modules' Build.cs files.
Look in:
*.Build.cs
*.Target.cs
*.uproject
*.upluginExamples:
PublicDependencyModuleNames.Add(
"FocusedInteraction"
);Regenerate project files
not 100% sure if this is reqired but it will force a clean compile.
Delete the geenerated files and generate new ones by right-clicking .uproject and regenerate project files.
I have a .bat file that helps delete generated files on my website.
Build
Open rider and Build. You might need to do the next step before launching UE.
Core Redirects (optional)
If Blueprint assets reference classes in the old module then you'll need to add a redirector.
[CoreRedirects]
+ClassRedirects=(
OldName="/Script/ContextualInteraction.",
NewName="/Script/FocusedInteraction."
)
Comments