I am utilizing the UI Dropdown part which helps you to set the textual content of an choice (OptionData
) solely. The worth of an choice is the index place within the choices checklist, so there is no such thing as a solution to set this.
My downside is that I’ve a dictionary
that I take advantage of to populate the dropdown choices, however I would really like the worth of the choice to be the id of the tile class, not the index place.
Edit:
I do know I can entry parts from the checklist by utilizing the worth (index).
checklist(dropdown.worth).id
However I needed to see about extending the dropdown with this small change, as I’ve another adjustments I want to make, however needed to start out with one thing easy first simply to get an concept of what’s possile.
I don’t want somebody to put up a full code resolution. Am largely after some pointers. Trying on the dropdown class, I do not see how I can prolong it to switch some issues (worth on this case), it seems like I must implement by personal model?
Some code will make this slightly clearer I feel:
// All tiles into checklist.
Checklist checklist = new Checklist(mydictionary.Values);
// Kind all tiles based mostly on the tile identify.
checklist.Kind((x,y) => x.identify.CompareTo(y.identify));
// Present method so as to add checklist to dropdown.
for(int i=0; i
Or if the worth is required internally for some purpose, then possibly an additional property that may be set and retrieved.
for(int i=0; i
I took a have a look at the DropDown
class to see if I may prolong it and add the “tile_id” choice in, however I acquired fully misplaced on what to do, as I’m nonetheless fairly new to C#.