Esempio n. 1
0
        private void Export(bool onlySelected)
        {
            Dictionary <string, object> entries = new Dictionary <string, object>();

            for (int i = 0; i < filteredPpeList.Count; i++)
            {
                PlayerPrefsEntry entry = filteredPpeList[i];
                if (!entries.ContainsKey(entry.Key))
                {
                    if (onlySelected == false)
                    {
                        entries.Add(entry.Key, entry.Value);
                    }
                    else if (entry.IsSelected)
                    {
                        entries.Add(entry.Key, entry.Value);
                    }
                }
            }

            if (onlySelected && entries.Count == 0)
            {
                Debug.LogError("Cannot export selected entries as no entries has been selected.");
            }
            else
            {
                string exportPath = EditorUtility.SaveFilePanel("Export all PlayPrefs entries", Application.dataPath, PlayerSettings.productName + "_PlayerPrefs", "ppe");

                if (!string.IsNullOrEmpty(exportPath))
                {
                    string xml = Prefslist.writeXml(entries);
                    File.WriteAllText(exportPath, xml);
                    AssetDatabase.Refresh();
                }
            }
        }
Esempio n. 2
0
 public static int SortByNameDescending(PlayerPrefsEntry a, PlayerPrefsEntry b)
 {
     return(string.Compare(b.Key, a.Key));
 }
Esempio n. 3
0
 public static int SortByNameDescending(PlayerPrefsEntry a, PlayerPrefsEntry b)
 {
     return string.Compare(b.Key, a.Key);
 }
Esempio n. 4
0
    private void OnImport()
    {
        string importPath = EditorUtility.OpenFilePanel("Import PlayerPrefs", "", "ppe");
        if (!string.IsNullOrEmpty(importPath))
        {
            FileInfo fi = new FileInfo(importPath);
            Dictionary<string, object> plist = (Dictionary<string, object>)PlistCS.Plist.readPlist(fi.FullName);

            foreach (KeyValuePair<string, object> kvp in plist)
            {
                PlayerPrefsEntry entry = null;
             
                if (kvp.Value is float)
                    entry = new PlayerPrefsEntry(kvp.Key, (float)kvp.Value);
                else if (kvp.Value is int)
                    entry = new PlayerPrefsEntry(kvp.Key, (int)kvp.Value);
                else if (kvp.Value is string)
                    entry = new PlayerPrefsEntry(kvp.Key, (string)kvp.Value);

                if (entry != null)
                {
                    ppeList.Add(entry);
                    entry.SaveChanges();
                }
            }
                    
            Sort();
            Repaint();
        }
    }