コード例 #1
0
        /// <summary>
        /// Load values found inside PlayerPrefs.
        /// </summary>
        private void LoadValues()
        {
            ResolutionIndex = PlayerPrefs.GetInt("SETTINGSMANAGER_RESOLUTIONINDEX", ResolutionIndex);

            if (ResolutionIndex <= -1)
            {
                Vector2Int currentResolution = new Vector2Int(Screen.currentResolution.width, Screen.currentResolution.height);

                bool exit = false;
                foreach (KeyValuePair <AspectRatioTypes, Vector2Int[]> aspectRatio in m_ResolutionList)
                {
                    for (int i = 0; i < aspectRatio.Value.Length; i++)
                    {
                        if (currentResolution == aspectRatio.Value[i])
                        {
                            ResolutionIndex = i;
                            AspectRatio     = aspectRatio.Key;
                            exit            = true;
                            break;
                        }
                    }

                    if (exit)
                    {
                        break;
                    }
                }

                if (ResolutionIndex == -1)
                {
                    // Standard 1080p
                    ResolutionIndex = 2;
                    AspectRatio     = AspectRatioTypes.Ratio16by9;
                }
            }
            else
            {
                AspectRatio = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_ASPECTRATIO", AspectRatio);
            }

            Fullscreen  = PlayerPrefsUtil.GetBool("SETTINGSMANAGER_FULLSCREEN", Fullscreen);
            RefreshRate = PlayerPrefs.GetInt("SETTINGSMANAGER_REFRESHRATE", RefreshRate);

            PixelLightCount         = PlayerPrefs.GetInt("SETTINGSMANAGER_PIXELLIGHTCOUNT", PixelLightCount);
            TextureQuality          = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_TEXTUREQUALITYTYPE", TextureQuality);
            AnisotropicFiltering    = PlayerPrefsUtil.GetBool("SETTINGSMANAGER_ANISOTROPICFILTERING", AnisotropicFiltering);
            AntiAliasing            = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_ANTIALIASING", AntiAliasing);
            SoftParticles           = PlayerPrefsUtil.GetBool("SETTINGSMANAGER_SOFTPARTICLES", SoftParticles);
            RealtimeReflectionProbe = PlayerPrefsUtil.GetBool("SETTINGSMANAGER_REALTIMEREFLECTIONPROBE", RealtimeReflectionProbe);
            VSyncCount = PlayerPrefs.GetInt("SETTINGSMANAGER_VSYNCCOUNT", VSyncCount);

            ShadowQualityType     = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_SHADOWQUALITYTYPE", ShadowQualityType);
            ShadowResolutionType  = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_SHADOWRESOLUTIONTYPE", ShadowResolutionType);
            ShadowProjectionType  = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_SHADOWPROJECTIONTYPE", ShadowProjectionType);
            ShadowDistance        = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_SHADOWDISTANCETYPE", ShadowDistance);
            ShadowmaskModeType    = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_SHADOWMASKMODE", ShadowmaskModeType);
            ShadowNearPlaneOffset = PlayerPrefs.GetInt("SETTINGSMANAGER_SHADOWNEARPLANEOFFSET", ShadowNearPlaneOffset);
            ShadowCascadeType     = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_SHADOWCASCADETYPE", ShadowCascadeType);
        }
コード例 #2
0
        /// <summary>
        /// Load values from a SettingPreset object including resolution.
        /// </summary>
        public void LoadValues(SettingsPreset preset, bool loadResolution)
        {
            if (loadResolution)
            {
                ResolutionIndex = PlayerPrefs.GetInt("SETTINGSMANAGER_RESOLUTIONINDEX", ResolutionIndex);

                if (ResolutionIndex <= -1)
                {
                    Vector2Int currentResolution = new Vector2Int(Screen.currentResolution.width, Screen.currentResolution.height);

                    bool exit = false;
                    foreach (KeyValuePair <AspectRatioTypes, Vector2Int[]> aspectRatio in m_ResolutionList)
                    {
                        for (int i = 0; i < aspectRatio.Value.Length; i++)
                        {
                            if (currentResolution == aspectRatio.Value[i])
                            {
                                ResolutionIndex = i;
                                AspectRatio     = aspectRatio.Key;
                                exit            = true;
                                break;
                            }
                        }

                        if (exit)
                        {
                            break;
                        }
                    }

                    if (ResolutionIndex == -1)
                    {
                        // Standard 1080p
                        ResolutionIndex = 2;
                        AspectRatio     = AspectRatioTypes.Ratio16by9;
                    }
                }
                else
                {
                    AspectRatio = PlayerPrefsUtil.GetEnum("SETTINGSMANAGER_ASPECTRATIO", AspectRatio);
                }

                Fullscreen  = PlayerPrefsUtil.GetBool("SETTINGSMANAGER_FULLSCREEN", Fullscreen);
                RefreshRate = PlayerPrefs.GetInt("SETTINGSMANAGER_REFRESHRATE", RefreshRate);
            }

            PixelLightCount         = preset.PixelLightCount;
            TextureQuality          = preset.TextureQuality;
            AnisotropicFiltering    = preset.AnisotropicFiltering;
            AntiAliasing            = preset.AntiAliasing;
            SoftParticles           = preset.SoftParticles;
            RealtimeReflectionProbe = preset.RealtimeReflectionProbe;
            VSyncCount = preset.VSyncCount;

            ShadowQualityType     = preset.ShadowQualityType;
            ShadowResolutionType  = preset.ShadowResolutionType;
            ShadowProjectionType  = preset.ShadowProjectionType;
            ShadowDistance        = preset.ShadowDistance;
            ShadowmaskModeType    = preset.ShadowmaskModeType;
            ShadowNearPlaneOffset = preset.ShadowNearPlaneOffset;
            ShadowCascadeType     = preset.ShadowCascadeType;
        }