top of page

How to Rename an Unreal Engine Module

2 days ago
2 min read

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.



  1. Rename the module folder


For a plugin:

Plugins/

└── YourPlugin/

└── Source/

└── ContextualInteraction/


becomes:

Plugins/

└── YourPlugin/

└── Source/

└── FocusedInteraction/



  1. Rename the Build.cs

inside the module folder, rename the .Build.cs file.

ContextualInteraction.Build.cs   ->  FocusedInteraction.Build.cs

Then 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)


  1. Update the module implementation

Rename the modules .h file

ContextualInteraction.h   ->  FocusedInteraction.h
ContextualInteraction.cpp   ->  FocusedInteraction.cpp

Rename the class name

class FContextualInteractionModule : public IModuleInterface

to

class FFocusedInteractionModule : public IModuleInterface

Rename everything in the .cpp file, including the IMPLEMENT_MODULE

IMPLEMENT_MODULE(FFocusedInteractionModule, FocusedInteraction)


  1. 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"
	}
],


  1. Update dependencies

Search the entire project for:

ContextualInteraction

and update references - e.g. check dependency references in other modules' Build.cs files.


Look in:

*.Build.cs
*.Target.cs
*.uproject
*.uplugin

Examples:

PublicDependencyModuleNames.Add(
    "FocusedInteraction"
);


  1. 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.



  1. Build

Open rider and Build. You might need to do the next step before launching UE.



  1. 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


bottom of page