Enum And Map

UE5 Enum can be added one by one after each other just by clicking the plus button , but My Enums are not like that. i have to change it then add another one.

and sorry if i don’t know how to talk or talk in a way u may don’t like, i don’t communicate much with people

hello.
i don’t know the answer but it’s an interesting question.
a hypothesis is that it might be a cpp thing. maybe a meta tag, or the one for iterating.

Can confirm it works. Adding

ENUM_RANGE_BY_FIRST_AND_LAST(ENumbers, ENumbers::one, ENumbers::three);

gives the same behavior. So set the enum and first and last value and you can keep clicking the plus value :slight_smile:

Example enum header file
Enums.h (297 Bytes)

1 Like

i still didn’t understand. blueprint?

You set the first and last part of the enum to be able to restrict the enum auto add process.
If you want the full range then just set the first element and last element of the enum.

Edited my above post to show it in engine.

what i don’t understand is what to do in blueprint? i’m not good at c++

i don’t know if you can do it in blueprints unfortunately. but i’m not 100% sure.
you’d need to define your enum in cpp like @3draven has shown.

where can i find this c++ class that i have to add my Enum? like the default one comes UE5

you have to create it yourself.
take a look at what 3draven did and pretty much copy it.

thouigh i would use another name for the files. though “enums” is all right.

i think he even attached the file that you can just download and put on your Source folder.
(also i prefer using the Count field, but that requires some extra knowledge)

i did but didn’t work for me. i don’t even have VS at all. i just used texteditor

if you haven’t installed vstudio (not vscode) then i doubt you can recompile the changes.
i’m not sure how you’re loading those cpp plugins though.

i rarely use plugins. i don’t compile my game often, still learning

then i’d say supporting enums on cpp will be more a headache than it’s worth for you.
i’d recommend you to wait a bit.

now, to address your need. what i’d recommend you is to define an default value that it’s unused. for example NONE, and put it first on the enum.
so when you add a value it always add None, then you change it.
at least it will allow you to work correctly.
And there are some cases where having None is good for your logic (for example checking default or invalid values).
I’ve use that in several cases.

example taken from another thread

UENUM(BlueprintType)
enum class GroundDirection : uint8 {
     NONE,
     DOWN,
     LEFT,
     UP,
     RIGHT
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.