private void OnGUI() { // Delete toutes les préférence de l'éditeur. DANGEREUX //EditorPref.DeleteALL(); int enumCount = System.Enum.GetNames(typeof(PrefsKey)).Length; for (int i = 0; i < enumCount; i++) { PrefsKey key = (PrefsKey)i; bool keyExists = EditorPrefs.HasKey(key.ToString()); EditorGUI.BeginDisabledGroup(!keyExists); if (GUILayout.Button("Remove " + key.ToString())) { EditorPrefs.DeleteKey(key.ToString()); GUI.FocusControl(""); } EditorGUI.EndDisabledGroup(); } m_Bool = EditorPrefs.GetBool(PrefsKey.Bool.ToString(), true); EditorGUI.BeginChangeCheck(); m_Bool = EditorGUILayout.Toggle("bool", m_Bool); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool(PrefsKey.Bool.ToString(), m_Bool); } m_Int = EditorPrefs.GetInt(PrefsKey.Int.ToString(), -1); EditorGUI.BeginChangeCheck(); m_Int = EditorGUILayout.IntField("INT", m_Int); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(PrefsKey.Int.ToString(), m_Int); } m_Float = EditorPrefs.GetFloat(PrefsKey.Float.ToString(), 10f); EditorGUI.BeginChangeCheck(); m_Float = EditorGUILayout.FloatField("Flaot", m_Float); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetFloat(PrefsKey.Float.ToString(), m_Float); } m_string = EditorPrefs.GetString(PrefsKey.String.ToString(), "Default"); EditorGUI.BeginChangeCheck(); m_string = EditorGUILayout.TextField("String", m_string); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetString(PrefsKey.String.ToString(), m_string); } }
public void SetFloat(PrefsKey prefsKey, float value) { string keyToStr = prefsKey.ToString(); PlayerPrefs.SetFloat(keyToStr, value); SaveEncryption(keyToStr, "float", Mathf.Floor(value * 1000).ToString()); }
public void SetInt(PrefsKey prefsKey, int value) { string keyToStr = prefsKey.ToString(); PlayerPrefs.SetInt(keyToStr.ToString(), value); SaveEncryption(keyToStr, "int", value.ToString()); }
public void SetString(PrefsKey prefsKey, string value) { string keyToStr = prefsKey.ToString(); PlayerPrefs.SetString(keyToStr, value); SaveEncryption(keyToStr, "string", value); }
public void DeleteKey(PrefsKey prefsKey) { string keyToStr = prefsKey.ToString(); PlayerPrefs.DeleteKey(keyToStr); PlayerPrefs.DeleteKey(keyToStr + "_encryption_check"); PlayerPrefs.DeleteKey(keyToStr + "_used_key"); }
public string GetString(PrefsKey prefsKey, string defaultValue) { string keyToStr = prefsKey.ToString(); string value = PlayerPrefs.GetString(keyToStr); if (!CheckEncryption(keyToStr, "string", value)) { return(defaultValue); } return(value); }
public int GetInt(PrefsKey prefsKey, int defaultValue) { string keyToStr = prefsKey.ToString(); int value = PlayerPrefs.GetInt(keyToStr); if (!CheckEncryption(keyToStr, "int", value.ToString())) { return(defaultValue); } return(value); }
public float GetFloat(PrefsKey prefsKey, float defaultValue) { string keyToStr = prefsKey.ToString(); float value = PlayerPrefs.GetFloat(keyToStr); if (!CheckEncryption(keyToStr, "float", Mathf.Floor(value * 1000).ToString())) { return(defaultValue); } return(value); }
public static bool GetKeyValue(PrefsKey prefsKey, out string value, out bool json) { string propertyName; string prefsManager; string type; value = ""; json = false; if (!ParseKeyString(prefsKey.ToString(), out propertyName, out type, out prefsManager)) { return(false); } IPrefsManager manager = GetManager(prefsManager); if (manager == null) { return(false); } switch (type) { case "Int": case "int": value = manager.GetInt(prefsKey, 0).ToString(); break; case "bool": case "Bool": value = manager.GetInt(prefsKey, 0) == 1 ? "true" : "false"; break; case "Float": case "float": value = manager.GetFloat(prefsKey, 0f).ToString(); break; case "String": case "string": value = manager.Get(prefsKey, ""); break; default: json = true; goto case "string"; } return(true); }
public float GetFloat(PrefsKey prefsKey, float defaultValue) { return(PlayerPrefs.GetFloat(prefsKey.ToString(), defaultValue)); }
public bool HasKey(PrefsKey key) { string keyToStr = key.ToString(); return(PlayerPrefs.HasKey(keyToStr)); }
public void SetString(PrefsKey prefsKey, string value) { PlayerPrefs.SetString(prefsKey.ToString(), value); }
public void SetInt(PrefsKey prefsKey, int value) { PlayerPrefs.SetInt(prefsKey.ToString(), value); }
public void SetFloat(PrefsKey prefsKey, float value) { PlayerPrefs.SetFloat(prefsKey.ToString(), value); }
public string GetString(PrefsKey prefsKey, string defaultValue) { return(PlayerPrefs.GetString(prefsKey.ToString(), defaultValue)); }
public string GetString(PrefsKey prefsKey) { return(PlayerPrefs.GetString(prefsKey.ToString())); }
public int GetInt(PrefsKey prefsKey, int defaultValue) { return(PlayerPrefs.GetInt(prefsKey.ToString(), defaultValue)); }
public int GetInt(PrefsKey prefsKey) { return(PlayerPrefs.GetInt(prefsKey.ToString())); }
public float GetFloat(PrefsKey prefsKey) { return(PlayerPrefs.GetFloat(prefsKey.ToString())); }
public void DeleteKey(PrefsKey key) { PlayerPrefs.DeleteKey(key.ToString()); }