TArray of a class that contains a UENUM passed to bp causes error

I have a function that adds a copy of AC_PickupItem to an array like that:

void AC_Ch_Player::AddToInventory(AC_PickupItem* PickedItem)
{
	Inventory.AddUnique(PickedItem);
}

where Inventory is declared as

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Player State")
		 TArray<AC_PickupItem*> Inventory;

and the UENUM is declared as

UENUM(BlueprintType)
enum EPickupItemType
{
	Remapper UMETA(DisplayName = "Control Remapper"),
	Shield UMETA(DisplayName = "Protective Shield"),
	SpeedUp UMETA(DisplayName = "Speed Booster"),
	SpeedDown UMETA(DisplayName = "Speed Reducer"),
	MapResetter UMETA(DisplayName = "Map Resetter")
};

and its variable is

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Properties")
		TEnumAsByte<EPickupItemType> ItemType;

now when I get the array and get the UENUM’s value and try to print it out, (as shown in the picture) it always goes through the first execute pin (control Remapper) no matter what the UENUM’s value is actually set to. I’m sure that it’s set correctly to different values because if i try to log it directly from C++ using UE_LOG it logs the correct value.

Any help would be appreciated. Thanks :slight_smile:

Why are you using TEnumAsByte<>? Did you try to remove it, and just leave the name of the Enum? In this case, do you still have the same behavior?

I’m using it because if I just type the Enum’s name I get this error:

Error: You cannot use the raw enum name as a type for member variables, instead use TEnumAsByte or a C++11 enum class with an explicit underlying type.

You get that error, because the enum is not declared as a class. Try to declare the enum like this:

UENUM(BlueprintType)
enum class EPickupItemType: uint8
 {
     Remapper UMETA(DisplayName = "Control Remapper"),
     Shield UMETA(DisplayName = "Protective Shield"),
     SpeedUp UMETA(DisplayName = "Speed Booster"),
     SpeedDown UMETA(DisplayName = "Speed Reducer"),
     MapResetter UMETA(DisplayName = "Map Resetter")
 };

And then use it without TEnumAsByte, and let me know.

Hi FSapio, sorry I took very long to reply.
I’ve tried changing it to enum class EPickupItemType: uint8 and declaring the enum variable as UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Properties") EPickupItemType ItemType;.
But to no avail. The problem still persists. Nothing changed.