That is not possible directly. Maybe as a workaround: create an int variable that you can access, that you set to the index of the option you want. I don’t think there is a better way to do this. If you don’t change the values of the Array you could make an enum that would do exactly what you want, but you would have to recompile each time that you want to change the options.
I’ve been digging around but I can’t seem to find a simple solution to this simple thing I am trying to do.
I have an array of strings that I would like to display in a combo box in the editor…
ideally I would just like to use a UPROPERTY macro on top of the Array of strings in my header file that would automatically just populate a combobox with the values.
Is this possible or do I have to create a widget and attach it to my component somehow?
Don’t worry, it’s easily done:
UPROPERTY(EditAnywhere) TArray<FString> MemberName;
You can then add stuff to the array in the details Panel.
Sorry, I don’t want to add stuff to the array. I just want to get the selected index of the option. Like a drop down menu for the array.
ok wait just so that I understand you correctly: You have an array that has strings in it, and you want to have a combobox ingame, that has all of these strings as selectable options. You then want to know which option was selected by the player. Is this correct?
Not in game. It will be part of the editor. I would like to customize the details property of a component.
I’m also looking for this answer. Is it really not possible to create a dropdown box of items created in script? I have a FString array that is populated from an external file that I want to be options in a combo box.
Hi, I know this is a bit too old, but in case it helps someone coming here:
It is possible to do so (if I understand well the problem), you have to create a Custom SGraphPin associated to a custom UStruct you can use as UPROPERTY. In this SGraphPin you can do what you want for your UI (Slate ComboBox) and to retrieve your data. To get an example of implementation, I freshly create a repo https://github.com/NansPellicari/UE4-HowTo-CustomPin, data are retrieved from a Custom Config, so you just have to change this part.
Hope it helps!
@pulp_user Hi, now I’m looking for something similar and I’ve figured out here how to implement what you want to using UPROPERTY meta argument GetOptions.