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

            if (keyName != null)
            {
                string value = EditorPrefs.GetString(keyName);
                SetStringNoEditorUpdate(k, value);
            }
        }
コード例 #2
0
        /// <summary>
        /// Sets the value of a string preference.
        /// </summary>
        /// <param name="k">The preference key.</param>
        /// <param name="value">The preference value.</param>
        public void SetString(StringPref k, string value)
        {
            SetStringNoEditorUpdate(k, value);
            EditorPrefs.SetString(GetKeyName(k), value);

            if (k.ObsoleteNames != null)
            {
                foreach (var obsoleteName in k.ObsoleteNames)
                {
                    EditorPrefs.DeleteKey(m_EditorPreferencesPrefix + obsoleteName);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Returns the value of a string preference.
 /// </summary>
 /// <param name="k">The preference key.</param>
 /// <returns>The value of the preference, or 0 if the preference was never set.</returns>
 public string GetString(StringPref k)
 {
     m_StringPrefs.TryGetValue(k, out var result);
     return(result);
 }
コード例 #4
0
 /// <summary>
 /// Sets the value of a string 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 SetStringNoEditorUpdate(StringPref k, string value)
 {
     m_StringPrefs[k] = value;
 }