Пример #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>
 /// Don't need SaveSystemAlt.StartWork(); and SaveSystemAlt.StopWorkAndClose();
 /// Saving array with key, use only English
 /// Don't use this on Update or FixedUpdate
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key">Name to save</param>
 /// <param name="array">Any array to save</param>
 public static void SetArray <T>(string key, T[] array)
 {
     if (array == null)
     {
         if (useDebug)
         {
             Debug.LogError("Array is null");
         }
         return;
     }
     string[] save = new string[1];
     save[0] = JsonHelper.ToJson(array, true);
     FilesSet.SaveStream("SaveSystemSL/Arrays/", "Array_" + key, "slsave", save, true);
 }
Пример #3
0
 /// <summary>
 /// Don't need SaveSystemAlt.StartWork(); and SaveSystemAlt.StopWorkAndClose();
 /// Loading array with key, use only English
 /// Don't use this on Update or FixedUpdate
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key">Name to save</param>
 /// <param name="array">Any array to save</param>
 public static T[] GetArray <T>(string key)
 {
     if (FilesSet.CheckFile("SaveSystemSL/Arrays/", "Array_" + key, "slsave", true))
     {
         if (useDebug)
         {
             Debug.LogError("Key not exist");
         }
         return(null);
     }
     else
     {
         return(JsonHelper.FromJson <T>(EasyDo.GetWWWString(Application.persistentDataPath + "/SaveSystemSL/Arrays/Array_" + key + ".slsave")));
     }
 }
Пример #4
0
        /// <summary>
        /// Alternative to StopWorkAndClose() in which you do not need to call StartWork() again to Get or Set data
        /// Like PlayerPrefs.Save()
        /// Don't call StartWork() after this function, use first StopWorkAndClose()
        /// </summary>
        public static void SaveUpdatesNotClose()
        {
            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);
        }
Пример #5
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));
            }
        }