Esempio n. 1
0
    public static bool SetString(string key, string v)
    {
        try
        {
            var child = PsdLayerPrefs.xml.CreateNode(XmlNodeType.Element, "Key", null);
            var name  = PsdLayerPrefs.xml.CreateAttribute("Name");
            var val   = PsdLayerPrefs.xml.CreateAttribute("Value");
            name.Value = key;
            val.Value  = v;
            child.Attributes.Append(name);
            child.Attributes.Append(val);

            var node = PsdLayerPrefs.root.SelectSingleNode("//Key[@Name='" + key + "']");
            if (node != null)
            {
                node = PsdLayerPrefs.root.ReplaceChild(child, node);
            }
            else
            {
                node = PsdLayerPrefs.root.AppendChild(child);
            }

            PsdLayerPrefs.Save();
        }
        catch (Exception e)
        {
            if (PsdLayerPrefs.verbose)
            {
                Debug.LogError(e.Message);
            }
            return(false);
        }
        return(true);
    }
Esempio n. 2
0
 public static string[] GetStringArray(string key, char separator)
 {
     if (PsdLayerPrefs.HasKey(key))
     {
         return(PsdLayerPrefs.GetString(key).Split(separator));
     }
     return(new string[0]);
 }
Esempio n. 3
0
 public static string[] GetStringArray(string key)
 {
     if (PsdLayerPrefs.HasKey(key))
     {
         return(PsdLayerPrefs.GetString(key).Split("\n"[0]));
     }
     return(new string[0]);
 }
Esempio n. 4
0
 public static bool SetStringArray(string key, params string[] strings)
 {
     if (!PsdLayerPrefs.SetStringArray(key, "\n"[0], strings))
     {
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
    public static string[] GetStringArray(string key, char separator, string defaultValue, int defaultSize)
    {
        if (PsdLayerPrefs.HasKey(key))
        {
            return(PsdLayerPrefs.GetString(key).Split(separator));
        }

        var strings = new string[defaultSize];

        for (int i = 0; i < defaultSize; i++)
        {
            strings[i] = defaultValue;
        }
        return(strings);
    }
Esempio n. 6
0
 public static bool SetStringArray(string key, char separator, params string[] strings)
 {
     try
     {
         if (strings.Length == 0)
         {
             PsdLayerPrefs.SetString(key, "");
         }
         else
         {
             PsdLayerPrefs.SetString(key, string.Join(separator.ToString(), strings));
         }
     }
     catch (Exception e)
     {
         if (PsdLayerPrefs.verbose)
         {
             Debug.LogError(e.Message);
         }
         return(false);
     }
     return(true);
 }
Esempio n. 7
0
 public static bool SetFloat(string key, float v)
 {
     return(PsdLayerPrefs.SetString(key, v.ToString()));
 }
Esempio n. 8
0
 public static bool SetInt(string key, int v)
 {
     return(PsdLayerPrefs.SetString(key, v.ToString()));
 }
Esempio n. 9
0
 public static string[] GetStringArray(string key, string defaultValue, int defaultSize)
 {
     return(PsdLayerPrefs.GetStringArray(key, "\n"[0], defaultValue, defaultSize));
 }
Esempio n. 10
0
    public static float GetFloat(string key, float defaultValue)
    {
        var ret = PsdLayerPrefs.GetString(key);

        return(!string.IsNullOrEmpty(ret) ? float.Parse(ret) : defaultValue);
    }
Esempio n. 11
0
    public static int GetInt(string key, int defaultValue)
    {
        var ret = PsdLayerPrefs.GetString(key);

        return(!string.IsNullOrEmpty(ret) ? int.Parse(ret) : defaultValue);
    }
Esempio n. 12
0
 public static string GetString(string key)
 {
     return(PsdLayerPrefs.GetString(key, ""));
 }
Esempio n. 13
0
 public static float GetFloat(string key)
 {
     return(PsdLayerPrefs.GetFloat(key, 0));
 }
Esempio n. 14
0
 public static int GetInt(string key)
 {
     return(PsdLayerPrefs.GetInt(key, 0));
 }