Question by
Frostbite23 · Dec 24, 2018 at 02:11 AM ·
c#uilists
Dynamically Populated Dropdown list has items with the same text
Hello, upon coding my video settings options menu I ran into a brick wall and it hurt.
So i'm trying to populate a video resolution drop down with the supported video resolutions of the system. Heres the unexpected result
But the odd thing is, checking the dropdowns option list, it has the correct names
so why isin't the items displaying the correct text? heres the code
//videoSettingsScreen.presetDropdown is a UI.Dropdown
public void PopulateVideoSettingsScreen()
{
Resolution[] resolutions = Screen.resolutions;
List<string> optionDatas = new List<string>();
foreach (Resolution resolution in resolutions)
{
optionDatas.Add(resolution.ToString());
}
videoSettingsScreen.presetDropdown.ClearOptions();
videoSettingsScreen.presetDropdown.AddOptions(optionDatas);
}
EDIT: i've tried instead of list of strings, ive tried dropdown.optiondata and still returning that unexpected result.
unity-2018-12-23-19-47-43.png
(29.8 kB)
unity-2018-12-23-19-38-59.png
(12.3 kB)
Comment
Best Answer
Answer by Frostbite23 · Dec 29, 2018 at 01:19 AM
Solved the issue, I accidentally unassigned the 'Item Text' property for the Dropdown in the inspector.