This is still necessary in 2022 and in UE 5.0.2. This post helped put me on the right track on how to do this for a C++ module refactor to move classes from the main game module to separate modules. The examples below assume just moving a class to a new module but a rename of the class would be analogous - just specify the new class name under NewName.
By trial and error and looking at the numerous examples in https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Config/BaseEngine.ini#L287 from Epic’s own engine refactoring, I discovered the following additional points that weren’t clear to me at least after reading through the earlier replies in this post:
- Changes go in an ini file under Config. Must be in a section called
[CoreRedirects]
Usually Config/DefaultEngine.ini makes the most sense and is what I used. - You use the “fully qualified name” of the class ONLY in NewName and not OldName.
[CoreRedirects]
; ... other redirects
+ClassRedirects=(OldName="MyCppClass",NewName="/Script/MyNewModule.MyCppClass")
- For UObject derived classes you omit the actor “A” or object “U” prefix
So if we have AMyActor in MyGameModule and we move it to MyCoreModule then the line is
+ClassRedirects=(OldName="MyActor",NewName="/Script/MyCoreModule.MyActor")
- For struct and enum types we include the FULL name of the class including any prefixes and they also have a different redirect key:
+StructRedirects=(OldName="FMyStruct",NewName="/Script/MyCoreModule.FMyStruct")
+EnumRedirects=(OldName="EMyEnum",NewName="/Script/MyCoreModule.EMyEnum")
I still got some nullptr access errors at runtime playing the game for some of the Uobject properties I refactored so I resaved the blueprints for good measure and the errors went away. This step may not be necessary but it is a good idea to resave the blueprints as then it saves them with the new name and then you will be able to eventually remove the redirects.