For internal engine purposes UnrealHeader tool adds an additional enum entry "EnumName_MAX" to the enum values, hence the runtime version returns different number.
A user reported that UEnum::NumEnums appears to be returning one more than the actual number of elements in the enum.
UENUM(BlueprintType) enum class EEnumExample : uint8 { EE_Dance UMETA(DisplayName = "Dance"), EE_Rain UMETA(DisplayName = "Rain"), EE_Song UMETA(DisplayName = "Song"), };
#include "MyEnumObject.h" #include "Engine.h"
int32 NumberOfEnums = 0; UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EEnumExample"), true); NumberOfEnums = EnumPtr->NumEnums(); if (GEngine) { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(NumberOfEnums)); }
RESULT:
The number "4" is output in the top left corner of the screen.
EXPECTED:
The number "3" is output in the top left corner of the screen.
Head over to the existing Questions & Answers thread and let us know what's up.
0 |
Component | UE - Foundation - Core |
---|---|
Affects Versions | 4.6.1, 4.8 |
Created | Jan 6, 2015 |
---|---|
Resolved | Jan 8, 2015 |
Updated | Feb 5, 2017 |