Download

[Quick Tip] Renaming C++ Classes without breaking your project

I just did a quick post on how to rename C++ classes without breaking your project. Hope you will find this information useful. :slight_smile:

Is there a way to “Fix up” the redirector, like what happens with materials? :slight_smile:

That’s a neat tip!

Thanks for sharing Satheesh!

:slight_smile:

:slight_smile:

Rama

Very cool tip. :slight_smile:

Wow awesome, i can change some ugly old names now :slight_smile:

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. :frowning:

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. :confused:

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