Use enum inside struct

I have a weapon class and in the header I am defining an enum that I would then like to include in a struct.

Code:

namespace EWeaponType{
	enum Type{
		Primary,
		Secondary,
		Tertiary,
		Shield,
	};
}

USTRUCT()
struct FMWeaponData{

	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditDefaultsOnly, Category = Usage)
	EWeaponType::Type WeaponType;

       .... ....

	// defaults 
	FMWeaponData(){
		WeaponType = EWeaponType::Primary;
		.... ....
	}

};

This is tossing "Unrecognized type ‘EWeaponType’ error at the line "EWeaponType::Type WeaponType;"

This is in the header later so the struct will appear in the blueprint for customization…

// weapon data 
	UPROPERTY(EditDefaultsOnly, Category = Config)
		FMWeaponData WeaponConfig;

I want to be able to define the values of this struct in the Editor when making blueprints for each weapon.

What am I doing wrong here?

Thanks!

Both of your suggested fixes were required and it worked like a charm. Thank you very much Jamie.

I assume that’s a UHT error.

Your enum needs a UENUM() tag before it:

UENUM()
namespace EWeaponType{
    enum Type{
        Primary,
        Secondary,
        Tertiary,
        Shield,
    };
}

You probably also need to use TEnumAsByte with the member variable too:

TEnumAsByte<EWeaponType::Type> WeaponType;