Is this code bad? It's causing a crash in 4.27!

When creating a function with parameter type TEnumAsByte it will crash on build. I thought this may have been a migration issue but this happens in an empty project. Anyone else had a crash relating to the Python Plugin? Also I don’t have a D drive…

Assertion failed: !GeneratedWrappedTypes.Contains(TypeRegistryName) [File:D:/Build/++UE4/Sync/Engine/Plugins/Experimental/PythonScriptPlugin/Source/PythonScriptPlugin/Private/PyWrapperTypeRegistry.cpp] [Line: 1780]

Here’s the code:

 enum Button
   N     UMETA(DisplayName = "N"),
   E     UMETA(DisplayName = "E"),
   S     UMETA(DisplayName = "S"),
   W     UMETA(DisplayName = "W"),
class EMPTY_API UMyDataAsset : public UDataAsset
	    uint8 ReturnTwo(TEnumAsByte<Button> SelectedButton);


uint8 UMyDataAsset::ReturnTwo(TEnumAsByte<Button> SelectedButton)
	return 2;

(Naturally the real code actually does something useful :wink: )

1 Like

TEnumAsByte is the old style for UENUMS.

All Enums should be prefixed with E and Enums should be enum class EButton : uint8

This means that TEnumAsByte, which I don’t think should be used as a parameter anyway is un-necessary, and can be changed to `ReturnTwo(EButton SelectedButton);

Finally, uint8 isn’t a blueprint compatible type as far as I’m aware - you should be using either int32, int, or int64. I could be wrong on that one, however.

Hey - thanks for your help that did it! I think uint8 is blueprint compatible (I’m using the function in a blueprint and it works). I believe that’s the C++ equivalent of a Byte.

I had some trouble getting any Data Assets to show up in a blank project but it imported fine now. Do you know why a Data Asset derived from the C++ class wouldn’t show up as a variable type?

Also, what makes that Enum declaration the old style by the way? Is there a docs file on that?

Thanks again!

Fair enough. You might want to just return EButton type and include UENUM(BlueprintType) as well then.

As for the data assets, I can’t remember if they have a UCLASS macro in the header file or something similar, but if they do, you’ll need to ensure that it contains Blueprintable.

I can’t remember where I saw it, but it’s quite common practice now that the new style of enum classes is just better in every way than the namespace method.

I’ll have an explore. Your help is much appreciated :slight_smile:

1 Like