Get number of elements in an ENUM?

Any way to do this in BP’s?

I can not find anything for this specifically. Perhaps convert it to an array then go from there, but that seems hackish.

Just do ‘Get Number of Entries in MY_ENUM’.


Or you can do Blueprint equivalent of something like

I don’t think that there is anything like that, every conversion just converts the current value, seeing as there is no sort of lastItem call. Now that I think of it, you might be wanting to do this for a dynamic enum, if that’s the case, you’ll need to convert it to an array, and then get the length.

Yeah convert to array and then array -> length seems to be it.

Just fyi, in the BP right click menu, type in the name of your array you will see a Get number of entries of <your enum name>. Confirmed it works in 4.10.4


Exactly what I needed. Just start typing “Get number of entries” and pick your enum from the list and it spits out an integer. Perfect!

Enums are considered as bytes so you can have the last entry in your enum be “MAX” and just get the byte value of MAX - 1

How? What node is that? I can not for the life of me find how to do that in BPs.

Very late response to the thread, but you can get this information through the UEnum field object.
UEnum* UMyFunctionLibrary::GetEnumFieldObject(const FString& enumName)
[INDENT=2]return FindObject<UEnum>(ANY_PACKAGE, *enumName);[/INDENT]

Example Usage:
UEnum* enumObj = UMyFunctionLibrary::GetEnumFieldObject(“EGetWorldErrorMode”);
int64 maxVal = enumObj->GetMaxEnumValue();

You can also use this for other things, such as to convert the current value of an enum into its string representation:
EGetWorldErrorMode errorMode = EGetWorldErrorMode::Assert;
FString enumString = enumObj->GetNameStringByIndex((uint32)errorMode);

Hope that helps anyone viewing this in the future!