I want to display values from a database to a drop-down list; how I can achieve this?
List<string> list = new List<string> { "option1", "option2" };
var dropdown = GetComponent<Dropdown>();
dropdown.options.Clear();
foreach (string option in list)
{
dropdown.options.Add(new Dropdown.OptionData(option));
}
I want to make these dynamic or sync with live db values.
I will also suggest, it is good to have the reference of dropdown via-inspector, instead of GetComponent. As GetComponent call is expensive!
Late answer, might be it would save someone's time!