コード例 #1
0
        void ReadBoolFromEditorPref(BoolPref k)
        {
            string keyName = GetKeyNameInEditorPrefs(k);

            if (keyName != null)
            {
                bool value = EditorPrefs.GetBool(keyName);
                SetBoolNoEditorUpdate(k, value);
            }
        }
コード例 #2
0
        /// <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);
                }
            }
        }
コード例 #3
0
 /// <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));
 }
コード例 #4
0
 /// <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);
 }
コード例 #5
0
 /// <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;
 }