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="<OLD_CLASS_NAME>",NewName="<NEW_CLASS_NAME>")
However, when redirecting to a symbol in a different module, or if either symbol exists in multiple modules, it may become necessary to specify the full namespace of the symbol, which is as follows:
+ClassRedirects=(OldName="/Script/<OLD_MODULE_NAME>.<OLD_CLASS_NAME>",NewName="/Script/<NEW_MODULE_NAME>.<NEW_CLASS_NAME>")
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="<OLD_BP_FILENAME>_C",NewName="<NEW_BP_FILENAME>_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="<OLD_BP_FILENAME>_C",NewName="/Script/<NEW_MODULE_NAME>.<NEW_CLASS_NAME>",OverrideClassName="/Script/CoreUObject.Class")
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="<OLD_BP_FILENAME>_C.<OLD_PROPERTY_NAME>",NewName="/Script/<NEW_MODULE_NAME>.<NEW_CLASS_NAME>.<NEW_PROPERTY_NAME>")
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/<OLD_BP_FILENAME>_C",NewName="/<NEW_PLUGIN_NAME>/<NEW_BP_FILENAME>_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)