예제 #1
0
        private void CreateResolutionDropdown(Resolution currentRes, FieldInfo field, GameObject panel)
        {
            Resolution[]  resolutions     = Screen.resolutions;
            List <string> resolutionsText = new List <string>();
            int           activeResIndex  = 0;

            //Find the active current resolution, as well as add each resolution option to the list of resolutions text
            for (int i = 0; i < resolutions.Length; i++)
            {
                if (resolutions[i].width == currentRes.width && resolutions[i].width == currentRes.width)
                {
                    activeResIndex = i;
                }

                resolutionsText.Add(resolutions[i].ToString());
            }

            //Create the dropdown, with all of our resolutions
            TMP_Dropdown dropdown =
                optionsPanel.AddDropdownToPanel(panel, field.GetObjectDisplayText(), resolutionsText.ToArray(),
                                                activeResIndex);

            dropdown.onValueChanged.AddListener(index =>
            {
                field.SetValue(GetSettingObject(field), resolutions[index]);
            });
        }