- Home /
UI dropdown index problem
I have following code and intention to debug selected value from drop down menu.
List<string> names = new List<string>()
{
"Easy",
"Medium",
"Hard"
};
public Dropdown dropdown;
public string SelectedName;
public void DropDown_IndexChanged(int index)
{
SelectedName = names[index];
Debug.Log("our selected difficulty is" + " " + SelectedName);
Debug.Log("our selected index is" + " " + index);
}
void Start()
{
PopulateList();
}
void PopulateList()
{
dropdown.AddOptions(names);
}
Problem is that what ever field I select from drop down menu, index and text is still the last one (index 2)
Any suggestion what would fix this problem ?
Comment
Best Answer
Answer by Tomy7777 · Jan 12, 2018 at 02:48 PM
Okay, so I just made new UI element dropdown again and it worked. I must have messed up something in UI before I made a script.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Button only works once 1 Answer
How to bold only the selected characters from a text? 3 Answers