void ReadBoolFromEditorPref(BoolPref k) { string keyName = GetKeyNameInEditorPrefs(k); if (keyName != null) { bool value = EditorPrefs.GetBool(keyName); SetBoolNoEditorUpdate(k, value); } }
/// <summary> /// Sets the value of a boolean preference. /// </summary> /// <param name="k">The preference key.</param> /// <param name="value">The preference value.</param> public void SetBool(BoolPref k, bool value) { SetBoolNoEditorUpdate(k, value); EditorPrefs.SetBool(GetKeyName(k), value); if (k.ObsoleteNames != null) { foreach (var obsoleteName in k.ObsoleteNames) { EditorPrefs.DeleteKey(m_EditorPreferencesPrefix + obsoleteName); } } }
/// <summary> /// Toggles the value of a boolean preference. /// </summary> /// <param name="k">The preference key.</param> public void ToggleBool(BoolPref k) { SetBool(k, !GetBool(k)); }
/// <summary> /// Returns the value of a boolean preference. /// </summary> /// <param name="k">The preference key.</param> /// <returns>The value of the preference, or false if the preference was never set.</returns> public bool GetBool(BoolPref k) { m_BoolPrefs.TryGetValue(k, out var result); return(result); }
/// <summary> /// Sets the value of a boolean preference without updating <see cref="EditorPrefs"/>. /// Use this function to set a value that should not be persisted, like a default value. /// </summary> /// <param name="k">The preference key.</param> /// <param name="value">The preference value.</param> public void SetBoolNoEditorUpdate(BoolPref k, bool value) { m_BoolPrefs[k] = value; }