コード例 #1
0
        /// <summary>
        /// Routine to update the screen resolution file.
        /// </summary>
        /// <param name="width">New width.</param>
        /// <param name="height">New height.</param>
        /// <param name="fullScreenMode">New mode.</param>
        private IEnumerator UpdateScreenResolutionFileRoutine(int width, int height, FullScreenMode fullScreenMode)
        {
            fileUpdating = true;

            while (configManager == null)
            {
                Logger.LogInfo("Waiting for config manager initialization.", this);
                yield return(waitForASecond);
            }

            ScreenConfiguration configData = new ScreenConfiguration
            {
                Width      = width,
                Height     = height,
                FullScreen = fullScreenMode
            };

            configManager.SetConfig(configData);

            fileUpdating = false;
        }
コード例 #2
0
        /// <summary>
        /// Routine to update the screen resolution from the config file.
        /// </summary>
        private IEnumerator UpdateScreenResolutionRoutine()
        {
            #if UNITY_EDITOR || UNITY_WEBGL
            Logger.LogWarning("Running on a platform unaffected by the resolution changer, not updating the resolution.",
                              this);

            yield break;
            #endif

            #pragma warning disable 162
            // ReSharper disable HeuristicUnreachableCode
            #pragma warning disable 162
            while (configManager == null)
            {
                Logger.LogInfo("Waiting for config manager initialization.", this);
                yield return(waitForASecond);
            }

            while (fileUpdating)
            {
                yield return(waitForASecond);
            }

            ScreenConfiguration config = configManager.GetConfig <ScreenConfiguration>();
            UnityEngine.Screen.SetResolution(config.Width, config.Height, config.FullScreen);

            Logger.LogInfo("Updated screen resolution to "
                           + config.Width
                           + "x"
                           + config.Height
                           + " on "
                           + config.FullScreen
                           + " mode.",
                           this);
            #pragma warning restore 162

            ResolutionUpdated?.Invoke(UnityEngine.Screen.width, UnityEngine.Screen.height);
        }