Пример #1
0
 /// <summary>
 /// Delete all kays from SSA file
 /// </summary>
 /// <param name="key">Name to delete</param>
 /// <param name="withFile">Delete file? (if true, don't use SaveSystemAlt.StopWorkAndClose();)</param>
 public static void DeleteAll(string key, bool withFile = false)
 {
     if (ss_sl == null)
     {
         if (useDebug)
         {
             Debug.LogError("Use SaveSystemAlt.StartWork(); first");
         }
         return;
     }
     if (withFile)
     {
         FilesSet.DelStream("SaveSystemSL/", "Save" + sindex_sl, "slsave", true);
         ss_sl     = null;
         sindex_sl = 0;
         Debug.Log("SSA file deleted");
     }
     else
     {
         ss_sl.name    = new List <string>();
         ss_sl.contain = new List <string>();
         ss_sl.type    = new List <SaveSystemSL.SSLTpe>();
         Debug.Log("All data deleted, use SaveSystemAlt.StopWorkAndClose(); to save");
     }
 }
Пример #2
0
        /// <summary>
        /// Close file, initialize this if you want saving new data or set new index
        /// Like PlayerPrefs.Save()
        /// </summary>
        public static void StopWorkAndClose()
        {
            if (ss_sl == null)
            {
                if (useDebug)
                {
                    Debug.LogError("You're not starting the work with SaveSystemAlt");
                }
                return;
            }
            string[] save = new string[1];
            save[0] = JsonUtility.ToJson(ss_sl, true);

            FilesSet.SaveStream("SaveSystemSL/", "Save" + sindex_sl, "slsave", save, true);

            ss_sl     = null;
            sindex_sl = 0;
        }
Пример #3
0
        /// <summary>
        /// Initialize this before you start working with SaveSystemAlt (SSA) in your code
        /// </summary>
        /// <param name="i">Index of SSA</param>
        public static void StartWork(int i = 0)
        {
            if (!(ss_sl == null) && useDebug)
            {
                Debug.LogError("Warning, you haven't closed old save");
            }

            ss_sl     = new SaveSystemSL();
            sindex_sl = i;
            if (FilesSet.CheckFile("SaveSystemSL/", "Save" + sindex_sl, "slsave", true))
            {
                if (useDebug)
                {
                    Debug.Log(FilesSet.LoadStream("SaveSystemSL/", "Save" + sindex_sl, "slsave", true, false));
                }
                ss_sl = JsonUtility.FromJson <SaveSystemSL>(FilesSet.LoadStream("SaveSystemSL/", "Save" + sindex_sl, "slsave", true, false));
            }
        }