Extract Struct list names for dropdown button

Hi! I want to put the items of a struct in a dropdown button.
How can I extract the string names of the items in a struct?

Thanks!
Dany

1 Like

I found a workaround but just because I know how many items has the struct I want to use in the dropdown and this is the workaround:

create a generic variable of the struct type

make a for loop that goes from 0 to the # of items-1

convert the index of the loop to byte and set in my generic struct variable so this way I can extrac his name…this looks too over-elaborated.

Is there a simpler way?

1 Like

It looks like this is an enum, not a struct. In blueprint, you can do a foreach for your enum as each blueprint-derived enum is open to reflection.

If I’m mistaken and this is indeed a struct, then C++ is the only way. You would need to make a TFieldItr on the class of the struct (which is much easier if you remake the struct as a USTRUCT in C++) then call GetName on each FProperty in the loop, add each name to an array then return the array to iterate on in BP.

Why Epic never exposed something like “GetStructNames” for all BP structs I’ll never know, but this is what you’ll have to do if you want this kind of functionality without having to know ahead of time what data you’re working with.

1 Like

Sorry…yes I mean ENUM, not struct.

How do for loop an enum class to extract the string names?
the only way I found was knowing the num of items and make a generic for loop, convert the index of the loop to byte and then set a variable of that enum class with the byte and then convert the variable to string.

1 Like

4 Likes

@JaredTherriault your’re the man!!

Thanks!!

2 Likes