Using Redirects with C++ Structs?

I’m currently moving a struct declared in c++ called MyStruct from a game project to a new plugin in a UE4.15 project. To facilitate this change not breaking a blueprint I added the following redirector:
+ActiveStructRedirects=(OldStructName=“MyStruct”,NewStructName="/Script/MyPlugin.MyStruct")

This works mostly fine. However I do have a problem with ‘Break MyStruct’ nodes. The pin is getting disconnected, I suspect because the ‘Break MyStruct’ is expecting an explicit MyStruct, rather than a MyPlugin.Mystruct. I figure there’s likely a redirector that I can use to fix up the parameter expected in ‘Break MyStruct’, however I don’t know the proper way to declare such in the .ini.

Ideas are welcome!

Hi,

Did you find a way to fix this?

I keep trying and I can’t make this work.

The error is using the old syntax. As of UE 5.0, you can add a struct redirect like so:

+StructRedirects=(OldName="/Script/MyGame.OldStructName", NewName="/Script/MyGame.NewStructName")

A few gotchas:

  1. The redirect system omits the ‘F’ in front of a struct name, even though Epic’s style guide requires it.
    So if your struct name is FOldStructName in c++, you need to type OldStructName in the StructRedirects (without the ‘F’). The above example would be correct when renaming FOldStructName to FNewStructName.

  2. If you’ve redirected the same struct more than once, you’ll need to update the old redirects as well.

So if redirect 1 looked like:

+StructRedirects=(OldName="/Script/MyGame.OldStructName", NewName="/Script/MyGame.NewStructName")

If you now want to call it NewStructName2, you’ll have to have this now:

+StructRedirects=(OldName="/Script/MyGame.OldStructName", NewName="/Script/MyGame.NewStructName2")
+StructRedirects=(OldName="/Script/MyGame.NewStructName", NewName="/Script/MyGame.NewStructName2")

So both of the previous names correctly redirect to the latest struct name. If you forget to update the old redirect, it will not resolve correctly.

Epic’s documentation covers this use-case: Core Redirects | Unreal Engine Documentation

1 Like

Thanks for info, but I cannot get it to work. This should work in editor too right?

What about “Script/MyGame.” part, should it be Scripts/TheNameOftheActualGame.StructName? Or this part should be as-is… or this should be direct path to .h file where this struct is defined?