Core Redirects
Redirecting renamed or moved Classes, Structs, Properties, Enums, Functions or Packages
If a symbol needs to be moved or renamed, Unreal provides the Core Redirects mechanism to override any instances of the old symbol with the new symbol. The data spec consists of a redirect for each symbol type that can be added to the DefaultEngine.ini file in your project, under the header [CoreRedirects]
.
The full specification can be found at the following link, however there are some things to take particular care of when redirecting between C++ and Blueprint.
- Unreal Documentation - Core Redirects (https://docs.unrealengine.com/en-US/ProgrammingAndScripting/ProgrammingWithCPP/Assets/CoreRedirects/index.html)
C++ Symbols
When redirecting from one C++ symbol to another in the same module, it may be sufficient to provide the short name of the symbol. For instance:
+ClassRedirects=(OldName="",NewName="")
However, when redirecting to a symbol in a different module, or if a symbol is duplicated in other modules, it may become necessary to specify the full namespace of the symbol, which is as follows:
+ClassRedirects=(OldName="/Script/.",NewName="/Script/.")
Blueprint Symbols
When redirecting Blueprint symbols, it's important to remember that, under-the-hood, Unreal suffixes all Blueprint class names with the extension "_C". For instance, a blueprint asset called BP_Item.uasset will actually have a class definition called BP_Item_C. This is enough to be able to redirect from one blueprint to another:
+ClassRedirects=(OldName="_C",NewName="_C")
However, when redirecting a Blueprint Class to a C++ Class, you also need to add OverrideClassName="/Script/CoreUObject.Class"
. Therefore, the full pattern to redirect a Blueprint Class to a C++ Class is as follows:
+ClassRedirects=(OldName="_C",NewName="/Script/.",OverrideClassName="/Script/CoreUObject.Class")
Versions of Unreal up to and including 4.26 do not support Blueprint member names containing whitespace in Core Redirects. This should be supported from 4.27.
Additional Examples
The above rules apply equally to other symbol types.
Redirecting a Blueprint Property to a C++ Property (e.g. when re-parenting):
+PropertyRedirects=(OldName="_C.",NewName="/Script/..")
If you wish to redirect Blueprints or other asset types between your game and a plugin, you must specify the plugin name in the path, or use "/Game/" to reference assets in any game module.
For instance, if a Blueprint Class has been moved from a game module to a plugin:
+ClassRedirects(OldName="/Game/_C",NewName="//_C")
Further Reading
- Unreal Documentation - Action RPG Example Project - Converting from Blueprints to C++ (https://docs.unrealengine.com/en-US/Resources/SampleGames/ARPG/BalancingBlueprintAndCPP/index.html)