[Redirectors Simplified]
Explained on this link, Core redirects serve as a way to update In-Editor assets for changes in Source code; changes relating to Class Name/Property Name/Function Name/Module_API changes. This post aims to further explain how they work and how to use them.
[Where to put them]
- For changes to Game Modules, they go in Project/Config/DefaultEngine.ini
- For changes to Project-only Plugins, they go in Project/Plugins/Config/DefaultYourPluginName.ini
- For changes to Engine-level Plugins, they go in /PluginDirectory/BaseYourPluginName.ini
[Rundown]
Extending from UE4’s docs, you can also visit the following links:
In this post’s examples, we’ll include 3 types of Redirectors: Enums, Structs, and a UClass. An important detail in general, is that there can only be one Class Name, meaning that you cannot have UMyClass and AMyClass.
First, we open with
[CoreRedirects]
Second, we go, line by line. Template Example:
[CoreRedirects]
+RedirectType=(OldName="/Script/ModuleName.ClassName",NewName="/Script/ModuleName.ClassName", MatchSubstring=true)
In a single redirect, you can update both the class name and Module name. Say that you had class AMyActor in ModuleA, and you’ve renamed it to AMyBicycle in ModuleB.
+RedirectType=(OldName="/Script/ModuleA.MyActor",NewName="/Script/ModuleB.MyBicycle", MatchSubstring=true)
Notes: Enumerators require EPrefix. Structs and UClasses, however, do not require it.
.../Script/ModuleName.EClassName //For enumerators
.../Script/ModuleName.ClassName //For UStruct/UClasses
RedirectorType Name Examples:
- Enumerator Redirect Name = EnumRedirects
- Struct Redirect Name = StructRedirects
- UClass Redirect Name = ClassRedirects
Once you’ve saved your .ini, Launch the Editor. Note that Core Redirectors are a heavy on Launch, so make sure to solve redirectors as quickly as possible. To address the redirectors, you must Load the Assets, Compile them (Where available), and resave them. Once all potential assets have been fixed, you may remove the Redirects from the configuration file.
Added, from @Hojo. A working example on redirecting a Blueprint Enum to a C++ UEnum.
+EnumRedirects=(OldName=”OverlayState”,NewName=”/Script/Module.EOverlayState”,OverrideClassName=”/Script/CoreUObject.Enum”,ValueChanges=((“NewEnumerator0″,”Default”),(“NewEnumerator2″,”UnarmedPosing”),(“NewEnumerator6″,”Firearm”)))