Literal enums are reset after hot reloading

Literal enums are reset in blueprints (at least in animBS) after hot reloading.
Everything becomes normal after restarting editor

Could you provide an example of what you mean by “reset”? Are they defaulting to 0, or what?

Hi 2rusbekov,

Could you provide some more information about the issue that you are experiencing?

  • What version of the Engine are you using?
  • Are you using the binary version of the Engine installed by the Launcher, or did you build the Engine from source code?
  • Are you able to reproduce this in a new project, or does it only occur in your own project?
  • Can you provide an example of one of the enums that this happens to?
  • What are the exact results that you see?

Hi 2rusbekov,

We have not heard from you for some time. Do you still need help with this issue? I will be marking this issue as resolved for tracking purposes, but if you need any additional help please feel free to re-open this post at any time.

I guess he’s not there, but I’m having this issue, if I’m understanding him right. To be specific, I have a “get” of a variable that is an enum, in animblueprint. I compare it against a constant enum in the blueprint. Most of the time, when I hot reload compiled C++ (where the enum comes from), it will break the BP compile, because the “get” changes from the proper enum, into a byte, and the node linkages to Enum nodes become compile errors.

for example:
Error Enum to String must have a valid enum defined
Warning Can’t connect pins Enumerator and My State : Input is not an Enum.
Error The current value (DiveBomb) of the ’ B ’ pin is invalid: Expected a valid unsigned number for a byte property
Error Unexpected node type K2Node_GetEnumeratorNameAsString encountered at Enum to String

Hi RogueRocket,

Sorry for the delayed response. I have a few questions for you.

  • What version of the Engine were you seeing this happen in?
  • Would it be possible to see the code where you are defining your Enum?
  • Was the Enum itself being changed when this happened, or were you hot reloading other changes to your code?

Hi 2rusbekov and RogueRocket,

We have not heard back from either of you for a while. Is this something that you are still needing help with? I will be marking this post as resolved for internal tracking purposes, but if you still need any assistance please feel free to add a comment and re-open this post at any time.

Sorry i wasn’t getting notifications for this for some reason . It is def still happening. Answers to your questions:

Currently on 4.8.3 but was happening as early as 4.7.x

here’s code where i’m defining (w/literals changed to make it project generic)

UENUM(BlueprintType)		//"BlueprintType" is essential to include
enum class ESomeState : uint8
{
	Normal 		UMETA(DisplayName = "Normal"),
	Grabbing	UMETA(DisplayName = "Grabbing"),
	Kicking		UMETA(DisplayName = "Kicking"),
	Smash		UMETA(DisplayName = "Smash"),
	DiveBomb	UMETA(DisplayName = "Divebomb"),
	Powerup	UMETA(DisplayName = "Powerup")
};

this happens when hot reloading changes to anything. The observed problem will be that some blueprint will be noted as failing to compile, and it will be because a place where i’m trying to something like “State” == ESomeState[literal]., for example in an animblueprint state transition rule.

Error will be something like:
Error The current value (GoalPowerup) of the ’ B ’ pin is invalid: Expected a valid unsigned number for a byte property

The underlying problem appears to be that somewhere along the way the blueprint variable (in this case an animblueprint) is no longer being displayed as an enum, it is instead, now a Byte.

just verified again, if i close editor and reload it, this problem goes away w/out any other changes.

Thank you for the code showing how you created your enum. I duplicated that enum in the header file for an Actor class, then created the following check in an anim state transition:

55725-enumcheck.png

Then I went back to the Actor class and added in a new UPROPERTY variable and set the default value in the code constructor and performed a hot reload. When I went back to the Anim Blueprint, the Blueprint did not show any indication of not having compiled successfully, and there were no errors when I looked at the state transition graph. Is the setup I have in the image above similar to how you were using the enum in your state transition graph?

it’s similar yes. What would appear to happen is that “state” variable would suddenly start getting interpretted as a Byte type rather than enum, and things would get all out of whack.

It doesn’t appear to happen every time any more, but it still does occur occasionally. In 4.7.x it happend every time almost, in 4.8.3 it happens occasionally. Either that or whatever extra conditions cause it that I haven’t sussed out was occurring more often. I really don’t know what is the difference between when it happens and when it does not.

I ran some more tests in both 4.7 and 4.8 with the setup I showed above, as well as with this setup:

I was unable to see a problem where the State variable was interpreted as a Byte instead of as the custom enum. I did see some issues in 4.7 where I was notified that the Blueprint could not be saved after the hot reload. That particular issue is one that I believe was corrected in 4.8 (where it did not occur for me).

When you perform a hot reload, do you generally start a build from inside Visual Studio, or do you click the Compile button in the Editor?

I personally almost always compile from Visual Studio to Development Editor target. This is not the case for all members of my team, who use the Compile button inside the editor almost exclusively. The problem has occurred in both scenarios.

I will try to take a screenshot the next time we see it.

Hi RogueRocket,

I just wanted to check in and see if you are still seeing this occur.

We saw it yesterday on one of our projects that is based on 4.9. it’s custom compiled engine though so it’s somewhat impure test. It’s collaborative with another company so I can’t say for sure what slice of 4.9 it’s branched from, but it’s unlikely there were any changes that would be related to this.

We haven’t had a recent test case on our main project which is still on 4.8, so i can’t say for sure on that one.

I’ll keep poking at it here to see if I can reproduce the issue myself.

Almost exact same problem as RougueRocket (also based on custom 4.9 derived engine…very small engine change completely unrelated). Our automated build system seems to have no issues…sometimes engineers get error and recompile the BP and all is fine - but sometimes restart editor to fix.

I still have not been able to reproduce this issue. If you happen to see this happen in a small test project, would you be able to zip it and provide that to us so we can take a look?

Hi everyone,

I have still not had any luck with reproducing this issue here. There is likely some small detail that I am still missing. I will continue to try to reproduce this periodically, but for now I will mark this as resolved for internal tracking purposes. If you have any additional information that you can provide, no matter how seemingly unimportant, or have a small sample project that reproduces the issue, please feel free to add a comment and re-open the post.

The issue definitely exists in 4.9.1-0. I found this page through Google by searching for the error message and “ue4 anim bp c++ enum”.

It’s a pretty crushing “showstopper” of a bug, because it makes the programmer think that the entire anim blueprint is broken.

The issue appears after building in Visual Studio with Unreal open. How many times, or what other things need to be touched to trigger it, is still an open question.

However, the “issue” seems to be resolved by exiting Unreal, rebuilding the DLL, and re-opening Unreal. Suddenly, magically, everything isn’t broken anymore.

In case that helps you track down the issue.

Hi Oreganik,

I just gave this another try in 4.10 Preview 3, but still had no luck reproducing the issue. Would it be possible to get a screenshot of how you are using the enum in your Anim BP?