Unreal Snippet: Core Redirectors

Unreal Snippet: Core Redirectors

Created
Aug 12, 2021 11:11 PM
Tags
C++SnippetBlueprints

There may come times when classes, enumerators, structures, and other such files need to be renamed while developing an Unreal Engine project. Doing so without proper consideration can cause catastrophic data loss due to the engine not recognizing those renamed assets. Thankfully, Epic has provided an easy solution for that — Core Redirectors.

Simply put, Core Redirectors is a method to tell Unreal Engine that X is now Y.

icon

If you end up finding this article useful — spread the word!

Where To Store The Redirectors

Core Redirectors should be placed in the following areas depending on the module.

Project
*/<ProjectName>/Config/DefaultEngine.ini

Project Plugin
*/<ProjectName>/Plugins/<PluginName>/Config/Default<PluginName>.ini

Engine Plugin
*/Epic Games/<UEVersion>/Engine/Plugins/<PluginPath>/<PluginName>/Config/<PluginName>.ini

Redirector Types

There are multiple different redirector types, and each type is approached differently.

icon

The redirectors must be placed within the [CoreRedirects] section of the .ini files.

icon

Make sure to replace the < > as well. Those are just indicators on what to change.

Package Redirector

+PackageRedirects=(OldName="/<OldName>/", NewName="/<NewName>/")

Class Redirector


; For redirecting within the same module
+ClassRedirects=(OldName="/Script/<ModuleName>.<OldClass>",NewName="/Script/<ModuleName>.<NewClass>")

; For redirecting between modules
+ClassRedirects=(OldName="/Script/<ModuleA>.<OldClass>",NewName="/Script/<MobuleB>.<NewClass>")

; For redirecting from a Blueprint Class to a Native C++ Class
+EnumRedirects=(OldName="<BlueprintClass>",NewName="/Script/<Module>.<NativeClass>",OverrideClassName="/Script/CoreUObject.Class")

Structure Redirector

; For redirecting within the same module
+StructRedirects=(OldName="/Script/<ModuleName>.<OldStruct>",NewName="/Script/<ModuleName>.<NewStruct>")

; For redirecting between modules
+StructRedirects=(OldName="/Script/<ModuleA>.<OldStruct>",NewName="/Script/<ModuleB>.<NewStruct>")

; For redirecting from a Blueprint Struct to a Native C++ Struct
+EnumRedirects=(OldName="<BlueprintStruct>",NewName="/Script/<Module>.<NativeStruct>",OverrideClassName="/Script/CoreUObject.Struct")

Enumerator Redirector

; For redirecting within the same module
+EnumRedirects=(OldName="/Script/<ModuleName>.<EOldStruct>",NewName="/Script/<ModuleName>.<ENewStruct>")

; For redirecting between modules
+EnumRedirects=(OldName="/Script/<ModuleA>.<EOldStruct>",NewName="/Script/<ModuleB>.<ENewStruct>")

; For redirecting from a Blueprint Enum to a Native C++ Enum
+EnumRedirects=(OldName="<EBlueprintEnum>",NewName="/Script/<Module>.<ENativeEnum>",OverrideClassName="/Script/CoreUObject.Enum")
icon

Unlike the other redirectors, enumerators require the E prefix.

Example

Here is an example utilizing the different redirector types.

[CoreRedirects]

; Plugin Redirector
+PackageRedirects=(OldName="/<OldGenericPlugin>/", NewName="/<NewGenericPlugin>/", MatchSubstring=true)

; Class Redirectors
+ClassRedirects=(OldName="/Script/<OldGenericPlugin.GenericActor>",NewName="/Script/<NewGenericPlugin.GenericActor>")
+ClassRedirects=(OldName="/Script/<OldGenericPlugin.OldGenericWidget>",NewName="/Script/<NewGenericPlugin.NewGenericWidget>")

; Struct Redirectors
+StructRedirects=(OldName="/Script/<OldGenericPlugin.GenericStruct>",NewName="/Script/<NewGenericPlugin.GenericStruct>")

; Enum Redirectors
+EnumRedirects=(OldName="/Script/<OldGenericPlugin.EGenericStruct>",NewName="/Script/<NewGenericPlugin.EGenericStruct>")

Tips

Here are some useful tips when dealing with Core Redirectors.

Safely Removing Redirectors

Redirectors can be safely removed once the affected assets, and the assets that use them, have been re-compiled and re-saved.

Warnings, errors, crashes oh no!

Do not worry! This just means that you are missing some redirectors. Carefully read through your Output Log for the cause.

Also, make sure you do not attempt to re-compile or re-save the assets that produce the issues. This can potentially cause the redirector to not work as intended. Especially for variables. If this does occur, you will have to manually go in and replace those variables.

Additional Information

You can find out more information via the official documentation.

icon

Thank you for reading!

My goal with Unreal Directive is to provide an extremely useful and easy to understand resource for Unreal Engine developers across all skill levels. Therefore, if you have found this article useful, spread the word! Please share it with your developer friends and peers. If you have a suggestion, or have come across an issue with the article, please message me via Twitter or via email.

Thank you,