void UpdateResolutions()          //TODO: OnResolutionChange event to refresh list for supporting dynamic screen swithing?
        {
            var           availableResolutions = Screen.resolutions;
            List <string> options         = new List <string>();
            int           currentResIndex = 0;
            var           currentRes      = new Vector2Int(Screen.width, Screen.height);

            for (int i = 0, len = availableResolutions.Length; i < len; i++)
            {
                var tempRes = new Vector2Int(availableResolutions[i].width, availableResolutions[i].height);
                if (!resolutions.Contains(tempRes))
                {
                    resolutions.Add(tempRes);
                    options.Add(tempRes.x + separator + tempRes.y);

                    if (tempRes.Equals(currentRes))
                    {
                        currentResIndex = resolutions.Count - 1;                       //Can't use i as index since a new list is built from the original
                    }
                }
            }
            dropdown.ClearOptions();
            dropdown.AddOptions(options);
            dropdown.value = currentResIndex;
            dropdown.RefreshShownValue();
        }
예제 #2
0
        void Awake()
        {
            //Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
            //Checking and Populating Resolutions
            resolutions = Screen.resolutions;

            resolutionDropdown.ClearOptions();

            List <string> options = new List <string>();

            int currentResolutionIndex = 0;

            for (int i = 0; i < resolutions.Length; i++)
            {
                string option = resolutions[i].width + " x " + resolutions[i].height;
                options.Add(option);

                if (resolutions[i].width == Screen.width && resolutions[i].height == Screen.height)
                {
                    currentResolutionIndex = i;
                }
            }
            resolutionDropdown.AddOptions(options);
            resolutionDropdown.value = currentResolutionIndex;
            resolutionDropdown.RefreshShownValue();

            //Checking Screen Mode for Fullscreen Settings Toggle
            CheckFullScreen();
        }
예제 #3
0
        void Start()
        {
            resolutionsDropdown.ClearOptions();
            List <string> resolutionOptions      = new List <string>();
            int           currentResolutionIndex = 0;

            for (int i = 0; i < resolutions.GetLength(0); i++)
            {
                if (resolutions[i, 0] <= Screen.resolutions[Screen.resolutions.Length - 1].width && resolutions[i, 1] <= Screen.resolutions[Screen.resolutions.Length - 1].height)
                {
                    resolutionOptions.Add(resolutions[i, 0] + " x " + resolutions[i, 1]);
                    if (resolutions[i, 0] == GameManager.instance.gsDataCurrent.resolutionWidth && resolutions[i, 1] == GameManager.instance.gsDataCurrent.resolutionHeight)
                    {
                        currentResolutionIndex = i;
                    }
                }
                else
                {
                    break;
                }
            }

            resolutionsDropdown.AddOptions(resolutionOptions);
            resolutionsDropdown.value = currentResolutionIndex;
            resolutionsDropdown.RefreshShownValue();
        }
예제 #4
0
        void Awake()
        {
#if TMP_PRESENT
            dropdown = GetComponent <TMPro.TMP_Dropdown>();
#else
            dropdown = GetComponent <UnityEngine.UI.Dropdown>();
#endif
            dropdown.ClearOptions();
            dropdown.AddOptions(new List <string>(QualitySettings.names));            //Convert names array to List and add it to the dropdown
            dropdown.value = QualitySettings.GetQualityLevel();
            dropdown.RefreshShownValue();

            dropdown.onValueChanged.AddListener((int _) => OnValueChange(_));             //UI classes use Unity events, requiring delegates (delegate() { OnValueChange(); }) or lambda expressions (() => OnValueChange()). Listeners are not persistent, so no need to unsub
        }
예제 #5
0
        private void Awake()
        {
            hostDropdown = GetComponent <TMPro.TMP_Dropdown>();

            if (initalizeMode == UixSyncInitializationMode.MatchVariable)
            {
                internalUpdate = true;

                if (valueVariable != null)
                {
                    hostDropdown.value = valueVariable.Value;
                }

                if (optionVariable != null)
                {
                    hostDropdown.options.Clear();
                    hostDropdown.options.AddRange(optionVariable.Value);
                }

                hostDropdown.RefreshShownValue();

                internalUpdate = false;
            }
            else if (initalizeMode == UixSyncInitializationMode.MatchUiControl && valueVariable != null)
            {
                internalUpdate = true;

                if (valueVariable != null)
                {
                    valueVariable.Value = hostDropdown.value;
                }

                if (optionVariable != null)
                {
                    optionVariable.Value = hostDropdown.options;
                }

                internalUpdate = false;
            }

            hostDropdown.onValueChanged.AddListener(HandleChange);
        }
        void UpdateResolutions()          //TODO: OnResolutionChange event to refresh list for supporting dynamic screen swithing?
        {
            resolutions = Screen.resolutions;
            List <string> options         = new List <string>();
            int           currentResIndex = 0;
            Resolution    currentRes      = Screen.currentResolution; //Fetching refreshrate

            currentRes.width  = Screen.width;                         //Overwrite width/height with screen values to get correct values in Windowed mode
            currentRes.height = Screen.height;

            for (int i = 0, len = resolutions.Length; i < len; i++)
            {
                options.Add(resolutions[i].ToString());

                if (resolutions[i].Equals(currentRes))
                {
                    currentResIndex = i;
                }
            }
            dropdown.ClearOptions();
            dropdown.AddOptions(options);
            dropdown.value = currentResIndex;
            dropdown.RefreshShownValue();
        }