# How to replace BP enums and structs with c++?

**URL:** <https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319>\
**Category:** Editor Scripting\
**Tags:** Struct, ustruct, unreal-engine, Blueprint, question, CPP\
**Created:** [July 18, 2016, 12:05am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319 "2016-07-18T00:05:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArtIntell](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtIntell](https://forums.unrealengine.com/u/ArtIntell)\
**Post date:** [July 18, 2016, 12:05am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/1 "2016-07-18T00:05:00Z")

</div>

How to replace blueprints structures and enums with C++ analogue? I know how to create c++ enums and structs that will be visible to BP, but I cannot find the way to replace references to existing objects ☹ And I have some structs that referenced more than 100 times…

---

<div class="post-metadata">

**Author:** ![vipeout](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vipeout](https://forums.unrealengine.com/u/vipeout)\
**Post date:** [July 18, 2016, 7:25am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/2 "2016-07-18T07:25:20Z")

</div>

Make the exact same name in c++ as they were in BP, they will auto-replace and the BP types will have \_0 added (the compiler will create new vars with BP types). At least that worked for me with enums, structs might be trickier and you might loose the inner data either way.

I started making them all c++, regardless of what I need. The content-based types also cause tons of issues when renamed / moved / changed after creating when being used and so on. Not very practical for anything bigger than a demo map.

---

<div class="post-metadata">

**Author:** ![ArtIntell](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtIntell](https://forums.unrealengine.com/u/ArtIntell)\
**Post date:** [July 18, 2016, 4:42pm UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/3 "2016-07-18T16:42:33Z")

</div>

No luck for me. Am I doing it wrong? I have blueprint enum “Enum\_RiddleType” and created c++ enum like this:

```
UENUM(BlueprintType, meta = (OverrideNativeName = "Enum_RiddleType"))
enum class Enum_RiddleType : uint8
{
	NewEnumerator0 = 0 UMETA(DisplayName = "Tutorial"),
	NewEnumerator1 = 1 UMETA(DisplayName = "Limited turns"),
	NewEnumerator2 = 2 UMETA(DisplayName = "Normal"),
	NewEnumerator3 = 3 UMETA(DisplayName = "Hard"),
	NewEnumerator4 = 4 UMETA(DisplayName = "OK"),
	Enum_MAX = 5,
};

/**
 * 
 */
UCLASS()
class TACTIC_API UCEnum_RiddleType : public UUserDefinedEnum
{
	GENERATED_BODY()
	
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Enum)
		Enum_RiddleType My_RiddleType;
};

```

Now I have two “Enum\_RiddleType” and BP one isn’t replaced (original has 4 members).  
Maybe there is a method to “replace” it when deleting BP enum? But I don’t see c++ enum in the list to replace - only other BP enums.

---

<div class="post-metadata">

**Author:** ![vipeout](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vipeout](https://forums.unrealengine.com/u/vipeout)\
**Post date:** [July 19, 2016, 6:10am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/4 "2016-07-19T06:10:02Z")

</div>

Create not only new type, but also a variable in c++ that uses this type, and name the variable exactly as the one you have in your BP. I probably should have been more clear about it. You don’t always need to create a type (just creating a native variable flagged as UPROPERTY(BlueprintReadWrite), but in this case you want to do so anyway, impossible to make a BP Enum variable in c++.

Then your BP should inherit from the native class you created that contains the variable in question (yes you need to create a class and then reparent the BP to use your own class). I found it a good habit, having always a native parent for your BP logic. Derive the native class from what your BP originally inherits (ie. AActor).

Hope this works.

---

<div class="post-metadata">

**Author:** ![ArtIntell](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtIntell](https://forums.unrealengine.com/u/ArtIntell)\
**Post date:** [July 23, 2016, 1:44pm UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/5 "2016-07-23T13:44:52Z")

</div>

No ☹ All links become broken. So, the “easiest” way is just to replace all by hands and it’s not funny. I thought migrating from blueprints to c++ is much easier and faster.

---

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [September 26, 2016, 4:42am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/6 "2016-09-26T04:42:41Z")

</div>

Yeah, it appears that structs and enums don’t replace as easily as Other blueprint types. Good thing I caught this relatively early. My issue is that I have to use my structs with templated functions and there’s no way to do that with blueprint structs. So, we’ve learned that it is best just to write all enums and structs as c++ types.

---

<div class="post-metadata">

**Author:** ![ArtIntell](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtIntell](https://forums.unrealengine.com/u/ArtIntell)\
**Post date:** [September 26, 2016, 7:17am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/7 "2016-09-26T07:17:43Z")

</div>

Absolutely

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0a080cf21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0a080cf21](https://forums.unrealengine.com/u/anonymous_user_0a080cf21)\
**Post date:** [April 4, 2018, 1:22am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/8 "2018-04-04T01:22:27Z")

</div>

Really? No way to replace blueprint struct with c++ struct automaticlly?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0a080cf21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0a080cf21](https://forums.unrealengine.com/u/anonymous_user_0a080cf21)\
**Post date:** [April 4, 2018, 1:23am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/9 "2018-04-04T01:23:14Z")

</div>

even in version 4.15?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e2ade227](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e2ade227](https://forums.unrealengine.com/u/anonymous_user_e2ade227)\
**Post date:** [April 4, 2018, 1:35am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/10 "2018-04-04T01:35:51Z")

</div>

Create Structs in C++ (different name, maybe add a preFix). Now when you delete the BP struct in the editor, it will ask you to replace reference? click on the C++ struct.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0a080cf21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0a080cf21](https://forums.unrealengine.com/u/anonymous_user_0a080cf21)\
**Post date:** [April 9, 2018, 1:07am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/11 "2018-04-09T01:07:55Z")

</div>

how to click on the c++ struct?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e2ade227](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e2ade227](https://forums.unrealengine.com/u/anonymous_user_e2ade227)\
**Post date:** [April 13, 2018, 9:14pm UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/12 "2018-04-13T21:14:08Z")

</div>

Did you get replace references option when you tried to delete the BP struct?

---

<div class="post-metadata">

**Author:** ![slaas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@slaas](https://forums.unrealengine.com/u/slaas)\
**Post date:** [September 20, 2018, 9:23am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/13 "2018-09-20T09:23:19Z")

</div>

In the view options filter for the “Replace References” list, “Show C++ Classes” is greyed out.

---

<div class="post-metadata">

**Author:** ![Two-faced](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Two-faced](https://forums.unrealengine.com/u/Two-faced)\
**Post date:** [July 3, 2019, 1:26pm UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/14 "2019-07-03T13:26:11Z")

</div>

Exactly. 4.22.3 still the same. Only manual work, only hardcore boys!

---

<div class="post-metadata">

**Author:** ![vipeout](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vipeout](https://forums.unrealengine.com/u/vipeout)\
**Post date:** [September 10, 2019, 6:10am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/15 "2019-09-10T06:10:05Z")

</div>

Finally found a way to do it! Only for enums, but still 😉 Writing here instead of a new answer so that you guys all get a notification. After creating the new enum in code and before launching the editor you must add an entry to the defaultengine.ini config in the [CoreRedirects] section. Goes like this:

```
+EnumRedirects=(OldName="OLD_ENUM_NAME_HERE",NewName="/Script/PROJECT_NAME_HERE.NEW_ENUM_NAME_HERE",OverrideClassName="/Script/CoreUObject.Enum",ValueChanges=(("NewEnumerator0","NEW_ENUM_VALUE_0"),("NewEnumerator1","NEW_ENUM_VALUE_1"),("NewEnumerator2","NEW_ENUM_VALUE_2")))

```

Of course, if you have more enum values you just keep adding the redirects between values. Now a little explanation:

OverrideClassName="/Script/CoreUObject.Enum" - this is what you use for a BP created enum. Every enum created in content instead of code has this class.

NewEnumerator0, NewEnumerator1 etc. - every content created enum has values in this fashion. I know you can change the name of each entry, but you are changing the display name, not the actual enum entries.

Verified in 4.23. Yeah I know, took a while, my first answer here is from mid 2016 😉 Actually wasn’t me who found it, just a fellow programmer on the team who had to replace several BP enums used all over the prototype project. He declined going with manual replace 😉

---

<div class="post-metadata">

**Author:** ![Levitikon217](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Levitikon217](https://forums.unrealengine.com/u/Levitikon217)\
**Post date:** [April 22, 2021, 10:07pm UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/16 "2021-04-22T22:07:35Z")

</div>

Confirming this works!

A note for anyone else trying this, follow everything about this exactly as it’s layed out. Coulda have saved myself several re-builds taking that advice. Set the ValueChanges even if the old names are the same as the new names. And use the NewEnumeratorX naming convention as the old names, I guess it’s how the BP enum is interpreted ¯\_(ツ)\_/¯ And, I found I had to invert the NewEnumerator indexes to keep existing assignments the same. Instead of 0, 1, 2, 3, 4 I had to go 4, 3, 2, 1, 0. (Even when the BP enum and C++ enum have the same values in the same order.)

E.g.,

```
+EnumRedirects=(OldName="EPK_StateAction",NewName="/Script/MyProjectName.EPK_StateAction2",OverrideClassName="/Script/CoreUObject.Enum",ValueChanges=(("NewEnumerator4","None"),("NewEnumerator3","NextState"),("NewEnumerator2","PrevState"),("NewEnumerator1","ResetState"),("NewEnumerator0","Restart")))
```

---

<div class="post-metadata">

**Author:** ![fsk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fsk](https://forums.unrealengine.com/u/fsk)\
**Post date:** [November 11, 2022, 5:55am UTC](https://forums.unrealengine.com/t/how-to-replace-bp-enums-and-structs-with-c/364319/17 "2022-11-11T05:55:10Z")

</div>

Sorry for reviving this old thread but it ranks high on google and I have something useful to add:).

As [Levitikon217](https://forums.unrealengine.com/u/Levitikon217) noticed the “NewEnumeratorXX” names may not be in order or have missing entries and be totally mixed up.  
An easy way to find out what maps to what is to go to the Enum asset in the content browser, then in the right click menu under asset actions find export. When you export you get a COPY file and in that file you can read the current mappings and use correct ones in the redirect command.

Had a really old enum that was modified many times and without this trick it was not going to work. Hope it helps someone:).
