private void Awake() { string type = typeof(T).ToString(); // Allows data to be kept over multiple sessions. m_ResultSize = new Vector2Int(PlayerPrefs.GetInt(type + "_RESULTSIZE_X", 512), PlayerPrefs.GetInt(type + "_RESULTSIZE_Y", 512)); string[] boxes = PlayerPrefsUtil.GetStringArray(type + "_BOXKEYS", string.Empty); foreach (string box in boxes) { string texturePath = PlayerPrefs.GetString(type + "_TEXPATH_" + box, string.Empty); Texture2D texture = null; if (texturePath != string.Empty) { Texture2D pathResult = AssetDatabase.LoadAssetAtPath <Texture2D>(texturePath); if (pathResult != null) { texture = pathResult; } } TextureColorContainer container = new TextureColorContainer( PlayerPrefsUtil.GetBool(type + "_ISCOLOR_" + box, false), texture, PlayerPrefsUtil.GetColor(type + "_COLOR_" + box, Color.black)); m_ComponentBoxes.Add(box, container); } SetSaveableValues(PlayerPrefsUtil.GetFloatArray(type + "_SAVEABLES")); }
/// <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); }
private void LoadAllSetting() { bool isAppLaunchedFirstTime = PlayerPrefsUtil.GetBool(PrefsConstant.KEY_IS_APP_LAUNCHED_FIRST_TIME); if (!isAppLaunchedFirstTime) { PlayerPrefsUtil.SetBool(PrefsConstant.KEY_IS_APP_LAUNCHED_FIRST_TIME, true); PlayerPrefsUtil.SetFloat(PrefsConstant.KEY_SOUND_VOLUME, 1f); PlayerPrefsUtil.SetFloat(PrefsConstant.KEY_MUSIC_VOLUME, 1f); PlayerPrefsUtil.SetFloat(PrefsConstant.KEY_GLOBAL_VOLUME, 1f); } mSoundVolume = PlayerPrefsUtil.GetFloat(PrefsConstant.KEY_SOUND_VOLUME); mMusicVolume = PlayerPrefsUtil.GetFloat(PrefsConstant.KEY_MUSIC_VOLUME); mGlobalVolume = PlayerPrefsUtil.GetFloat(PrefsConstant.KEY_GLOBAL_VOLUME); //Debug.Log("Load " + mSoundVolume); //Debug.Log("Load " + mMusicVolume); //Debug.Log("Load " + mGlobalVolume); }
static bool IsMuted(string key) { return(PlayerPrefsUtil.GetBool(key)); }
/// <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; }