Ejemplo n.º 1
0
        public void SetInt(PrefsKey prefsKey, int value)
        {
            string keyToStr = prefsKey.ToString();

            PlayerPrefs.SetInt(keyToStr.ToString(), value);
            SaveEncryption(keyToStr, "int", value.ToString());
        }
Ejemplo n.º 2
0
        public void SetFloat(PrefsKey prefsKey, float value)
        {
            string keyToStr = prefsKey.ToString();

            PlayerPrefs.SetFloat(keyToStr, value);
            SaveEncryption(keyToStr, "float", Mathf.Floor(value * 1000).ToString());
        }
Ejemplo n.º 3
0
        public void SetString(PrefsKey prefsKey, string value)
        {
            string keyToStr = prefsKey.ToString();

            PlayerPrefs.SetString(keyToStr, value);
            SaveEncryption(keyToStr, "string", value);
        }
Ejemplo n.º 4
0
        public IPrefsManager GetManager(PrefsKey prefsKey)
        {
            IPrefsManager manager;

            _keyManagers.TryGetValue(prefsKey, out manager);

            return(manager);
        }
Ejemplo n.º 5
0
        public void DeleteKey(PrefsKey prefsKey)
        {
            string keyToStr = prefsKey.ToString();

            PlayerPrefs.DeleteKey(keyToStr);
            PlayerPrefs.DeleteKey(keyToStr + "_encryption_check");
            PlayerPrefs.DeleteKey(keyToStr + "_used_key");
        }
Ejemplo n.º 6
0
        public T Get <T>(PrefsKey prefsKey, T defaultValue)
        {
            string val = GetString(prefsKey, "");

            if (string.IsNullOrEmpty(val))
            {
                return(defaultValue);
            }

            return(JsonConverter.Deserialize <T>(GetString(prefsKey)));
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 public T Get <T>(PrefsKey prefsKey)
 {
     try
     {
         return(JsonConverter.Deserialize <T>(GetString(prefsKey)));
     }
     catch (Exception e)
     {
         Debug.LogError(e);
         return(default(T));
     }
 }
Ejemplo n.º 11
0
    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);
        }
    }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        public T Get <T>(PrefsKey prefsKey, T defaultValue)
        {
            string val = GetString(prefsKey, "");

            if (string.IsNullOrEmpty(val))
            {
                return(defaultValue);
            }

            try
            {
                return(JsonConverter.Deserialize <T>(val));
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                return(default(T));
            }
        }
Ejemplo n.º 14
0
 public void SetString(PrefsKey prefsKey, string value)
 {
     PlayerPrefs.SetString(prefsKey.ToString(), value);
 }
Ejemplo n.º 15
0
 public void SetInt(PrefsKey prefsKey, int value)
 {
     PlayerPrefs.SetInt(prefsKey.ToString(), value);
 }
Ejemplo n.º 16
0
 public void SetFloat(PrefsKey prefsKey, float value)
 {
     PlayerPrefs.SetFloat(prefsKey.ToString(), value);
 }
Ejemplo n.º 17
0
 public void Set <T>(PrefsKey prefsKey, T value)
 {
     SetString(prefsKey, JsonConverter.Serialize(value));
 }
Ejemplo n.º 18
0
 public string GetString(PrefsKey prefsKey, string defaultValue)
 {
     return(PlayerPrefs.GetString(prefsKey.ToString(), defaultValue));
 }
Ejemplo n.º 19
0
 public string GetString(PrefsKey prefsKey)
 {
     return(PlayerPrefs.GetString(prefsKey.ToString()));
 }
Ejemplo n.º 20
0
 public int GetInt(PrefsKey prefsKey, int defaultValue)
 {
     return(PlayerPrefs.GetInt(prefsKey.ToString(), defaultValue));
 }
Ejemplo n.º 21
0
 public int GetInt(PrefsKey prefsKey)
 {
     return(PlayerPrefs.GetInt(prefsKey.ToString()));
 }
Ejemplo n.º 22
0
 public float GetFloat(PrefsKey prefsKey, float defaultValue)
 {
     return(PlayerPrefs.GetFloat(prefsKey.ToString(), defaultValue));
 }
Ejemplo n.º 23
0
 public float GetFloat(PrefsKey prefsKey)
 {
     return(PlayerPrefs.GetFloat(prefsKey.ToString()));
 }
Ejemplo n.º 24
0
 public string GetString(PrefsKey prefsKey)
 {
     return(GetString(prefsKey, ""));
 }
Ejemplo n.º 25
0
 public float GetFloat(PrefsKey prefsKey)
 {
     return(GetFloat(prefsKey, 0f));
 }
Ejemplo n.º 26
0
        public bool HasKey(PrefsKey key)
        {
            string keyToStr = key.ToString();

            return(PlayerPrefs.HasKey(keyToStr));
        }
Ejemplo n.º 27
0
 public T Get <T>(PrefsKey prefsKey)
 {
     return(JsonConverter.Deserialize <T>(GetString(prefsKey)));
 }
 public static void SetData(PrefsKey prefsKey, string dataToAssign)
 {
     PlayerPrefs.SetString("" + prefsKey, dataToAssign);
 }
Ejemplo n.º 29
0
 public void DeleteKey(PrefsKey key)
 {
     PlayerPrefs.DeleteKey(key.ToString());
 }
Ejemplo n.º 30
0
 public int GetInt(PrefsKey prefsKey)
 {
     return(GetInt(prefsKey, 0));
 }