- Home /
The question is answered, right answer was accepted
How do you remove items from a dropdown?
I have several identical TextMeshPro dropdowns, all with the same options. I would like to make it so once one of the options is picked in one of the dropdowns it is removed from all the other ones.
I found the dropdown.options.Remove() method but can't figure out what parameters it takes. Please help out me with this.
Answer by Hellium · Aug 13, 2019 at 11:58 AM
dropdown.options
is a List
, so you need to look at the documentation to know which function you have to call.
You can call Remove
, but you need to have a reference to the element to remove
OptionData option = dropdown.options.Find( o => string.Equals( o.text, "some text" ) ) ;
dropdown.options.Remove( option ) ;
You can call RemoveAt
, which takes an index as argument
dropdown.options.RemoveAt( 1 ) ; // Remove the 2nd option
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
UI won't activate 1 Answer
Getting dynamic indicies from multiple dropdown menus 0 Answers
Dropdown like menus in the inspector 2 Answers