How to use core redirects on an enum

If I’m understanding the core redirect system correctly, I should be able to use it to route all references from a BP to an equivalent C++ asset. I would like to do this with an enum in order to convert the enum from BP to C++ without having to manually replace every reference to that BP enum.

My C++ enum is set up like this in a file called “FooEnum.h”

 #include "ObjectMacros.h"
 
 UENUM(BlueprintType) 
 enum class EFooEnum : uint8
 {
     Foo,
     Bar,
 };

My core redirect is as follows

 [CoreRedirects]
 +EnumRedirects=(OldName="ENUM_Foo", NewName="/Script/MyGame.FooEnum", OverrideClassName="/Script/CoreUObject.Enum", ValueChanges=(("Foo", "EFooEnum::Foo"), ("Bar", "EFooEnum::Bar"))

When I load the project, I get a string of errors reading “Failed to lead /Script/MyGame.FooEnum”. Is this a problem with my header, a problem with the core redirect, or am I trying to do something with the core redirect that should not be done?

Edit: I tried shortening the core redirect to +EnumRedirects=(OldName=“ENUM_Foo”, NewName=“/Script/MyGame.FooEnum”) as seen in the UE4 source but this crashes the engine on launch with “Assertion failed: InPos >= 0 && InPos <= TotalSizeOrMaxInt64IfNotReady()”

Did you get this to work? I am trying to do the same tning.

In terms of using Core Redirects, to convert a blueprint enum to C++, I was able to get the code below to work, when adding it to my project’s DefaultEngine.ini.

In my blueprints, the Enum .uasset was called GettingShotBodyParts. The Enum defined in my C++ was called EBodyPartsForShooting

Note: Internally, all of the blueprint Enum values are called NewEnumerator0, NewEnumerator1, NewEnumerator2. This is true for every Unreal Project.

[CoreRedirects] +EnumRedirects=(OldName=“GettingShotBodyParts”,NewName="/Script/MyProject5.EBodyPartsForShooting",OverrideClassName="/Script/CoreUObject.Enum",ValueChanges=((“NewEnumerator0”,“EBodyPartsForShooting::PART_Head”),(“NewEnumerator1”,“EBodyPartsForShooting::PART_Neck”),(“NewEnumerator2”,“EBodyPartsForShooting::PART_Pec_Left”),(“NewEnumerator3”,“EBodyPartsForShooting::PART_Pec_Right”),(“NewEnumerator4”,“EBodyPartsForShooting::PART_Foot_Left”),(“NewEnumerator5”,“EBodyPartsForShooting::PART_Foot_Right”),(“NewEnumerator6”,“EBodyPartsForShooting::PART_None”)))

8 Likes