In some UObject derived class:
...
UENUM(BlueprintType)
enum class EEnumExample: uint8 {
SomeEnum
};...
and
In some other UClass that includes whatever header EnumExample exists in:
...
int32 numberOfEnums = 0;
//following the wiki example on UEnums by
UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EEnumExample"), true);
numberOfEnums = EnumPtr->NumEnums();
...
numberOfEnums prints out 2, instead of 1. Is this an off-by-one bug? or am I doing something wrong?
I ran some tests on NumEnums, and there does appear to be a discrepancy between the number returned and the actual number of elements in the enum. I have submitted a report about this to have it investigated further (UE-7199).
I just wanted to provide a quick update on this issue. It actually looks like this is happening by design. For internal Engine purposes, the UnrealHeaderTool adds an additional element to the Enum: EnumName_MAX
You will want to make sure to take this into consideration when counting the number of elements are in an Enum.