我正在尝试删除下拉菜单中的某些分辨率。我要删除,因为我不会使用它。这就是我所做的(请参见下面的代码),
我尝试过的事情:
resolutions = Screen.resolutions;
foreach(Resolution resolution in resolutions) {
for (int i = 0; i < resolutions.Length; i++) {
if (resolutionDropdown.options[i].text == "320 x 200") {
resolutionDropdown.options.RemoveAt(i);
break;
}
}
resolutionDropdown.options.Add(new TMPro.TMP_Dropdown.OptionData(ResolutionToString(resolution)));
}
但我收到此错误:
ArgumentOutOfRangeException:
Argument is out of range. Parameter name: index
System.Collections.Generic.List1[TMPro.TMP_Dropdown+OptionData].get_Item (Int32 index)
(at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
SettingsManager.OnEnable ()
(at Assets/Scripts/Settings/SettingsManager.cs:38)
答案 0 :(得分:0)
resolutions = Screen.resolutions;
foreach (Resolution resolution in resolutions)
{
if (ResolutionToString(resolution) != "320 x 200")
resolutionDropdown.options.Add(new TMPro.TMP_Dropdown.OptionData(ResolutionToString(resolution)));
}