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); }
public static string[] GetStringArray(string key, char separator) { if (PsdLayerPrefs.HasKey(key)) { return(PsdLayerPrefs.GetString(key).Split(separator)); } return(new string[0]); }
public static string[] GetStringArray(string key) { if (PsdLayerPrefs.HasKey(key)) { return(PsdLayerPrefs.GetString(key).Split("\n"[0])); } return(new string[0]); }
public static bool SetStringArray(string key, params string[] strings) { if (!PsdLayerPrefs.SetStringArray(key, "\n"[0], strings)) { return(false); } return(true); }
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); }
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); }
public static bool SetFloat(string key, float v) { return(PsdLayerPrefs.SetString(key, v.ToString())); }
public static bool SetInt(string key, int v) { return(PsdLayerPrefs.SetString(key, v.ToString())); }
public static string[] GetStringArray(string key, string defaultValue, int defaultSize) { return(PsdLayerPrefs.GetStringArray(key, "\n"[0], defaultValue, defaultSize)); }
public static float GetFloat(string key, float defaultValue) { var ret = PsdLayerPrefs.GetString(key); return(!string.IsNullOrEmpty(ret) ? float.Parse(ret) : defaultValue); }
public static int GetInt(string key, int defaultValue) { var ret = PsdLayerPrefs.GetString(key); return(!string.IsNullOrEmpty(ret) ? int.Parse(ret) : defaultValue); }
public static string GetString(string key) { return(PsdLayerPrefs.GetString(key, "")); }
public static float GetFloat(string key) { return(PsdLayerPrefs.GetFloat(key, 0)); }
public static int GetInt(string key) { return(PsdLayerPrefs.GetInt(key, 0)); }