Can't use enums in namespace

I have created the following UENUM in another header file and I’ve included it in my preferred header file to use it as a UPROPERTY. The problem is that when I place my enum in a namespace, I get Cannot find class '', to resolve delegate 'ENUMTYPE'. As soon as I have it out of the namespace, everything turns out to be fine. What could the problem be here?

namespace CAIAnimations
{
	UENUM(BlueprintType)
	enum class EMovementBSs : uint8
	{
		Default = 0,
		IdleTurning = 1
	};
}

And I use it in another class:

UPROPERTY(EditAnywhere)
CAIAnimations::EMovementBSs SomeName;

You can, but you have to put the UENUM at namespace level.

However that is not recommended. See guidelines here.

2 Likes

Alternatively, you can do it but you can’t make it a UENUM (and ultimately not a UPROPERTY).

In general, namespaces are not supported in UE4/5 when also dealing with any of the engine reflection support. The one exception being the old style enumeration support where the only contents of the namespace is a specifically named enumeration. But that use case has (in general) been replaced by the use/support of enum class enumerations.

1 Like