I just did a quick post on how to rename C++ classes without breaking your project. Hope you will find this information useful.
Is there a way to âFix upâ the redirector, like what happens with materials?
Thatâs a neat tip!
Thanks for sharing Satheesh!
Rama
Very cool tip.
Wow awesome, i can change some ugly old names now
Thank you for the tip !
Yeah, ActiveClassRedirects is a very useful feature. Unfortunately this feature (like many other cool features in the engine) is not documented.
Thereâs also ActiveGameNameRedirects that allows you to rename your whole game module. Hereâs some example I googled that uses it: BrickGame/DefaultEngine.ini at master ¡ AndrewScheidecker/BrickGame ¡ GitHub
While it might be super useful, it didnât affect the #include sections. ActuallyâŚit affected some, which is really weird. Anyways, itâs a thing that should really be easierâŚI wish they will make a fix. But this current fix should definitely be documented.
Is there a solution if the entire module was renamed? I am trying to rename a project where we used to have a module âAâ that we now want called âBâ (for context, âAâ was the name of our first customer, and âBâ is now the name of our company as it makes more sense moving forward).
I renamed and updated all the C++ side, that part seems fine. But all the blueprints are now failing to compile, not finding the C++ functions that are now in B, complaining âCanât find file â/Script/Aââ - trying to find a way to reprocess all those blueprint .uasset to point to /Script/B now⌠any suggestions?
Thereâs some documentation on these redirects hidden in the config file:
https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Config/BaseEngine.ini#L240
Iâm assuming if you rename an entire module, you would use a package redirect, resave all of the assets, then get rid of it again⌠maybe?
Thank you @Zeblote, this worked really well, with an entry like so:
Now I can either leave this entry permanently, or go find all the assets that are affected and re-save them. That part is a little annoying as there is no good way to process everything afaik.
What if youâve moved some classes from one module to another, but not all of them? A package redirect wouldnât work because it would redirect the entire package. Iâve tried the following and it didnât work.
[/Script/Engine.Engine]
+ActiveClassRedirects=(OldClassName=âOldModuleName.ClassNameâ,NewClassName=âNewModuleName.ClassNameâ)
The parent class of my blueprint is now None and my class is not available in the drop-down for reparenting, even though I can create a new blueprint from that same class.
Youâre missing the /Script/ part in your redirect. For example:
+ClassRedirects=(OldName=âClassNameâ, NewName="/Script/NewModule.ClassName")
I figured out how to do mine. I created a duplicate class in the new module and appended â1â to the name, so ClassName1. Then opened the editor, re-parented blueprints to ClassName1 from ClassName. Saved all in editor and closed editor. Removed ClassName from old module and renamed ClassName1 to ClassName in new module.
Changed redirect to:
And everything worked.
Thanks, will try that.
YEP, that was my problem. Geesh. Thanks Zeblote.
For some reason it didnât work with all my gameplay tag references. I think I have to make the redirect package work and give up on piecemeal approach.
In 2020, is this still necessary? What is the alternative, just a rename, rebuild and then reparent all your blueprints manually? There must be an engine feature to do this automatically, this is the easiest thing in the world in Unity and Unreal is supposed to have a lot more features than Unity
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.
For those people (like me), who are trying to follow these steps and still getting lots of warnings from Editor: after closing Editor and adding this line in .ini file, you should first rebuild your project and only then open Editor again
(post deleted by author)