예제 #1
0
        public static string ToText <T>(T obj, bool zip = false, bool pretty = true)
        {
            string ret = string.Empty;

            try {
                ret = UnityEngine.JsonUtility.ToJson(obj, pretty);
                if (zip)
                {
                    var zipcontent = Zip7Helper.CompressLZMA(sUTF8NBOM.GetBytes(ret));
                    ret = sUTF8NBOM.GetString(zipcontent);
                }
            } catch (Exception exc) {
                UnityEngine.Debug.LogWarning(exc.Message);
            }
            return(ret);
        }
예제 #2
0
 public static bool SaveJsonObject <T>(T obj, string path, bool zip = false)
 {
     try {
         string content = JsonUtility.ToJson(obj, true);
         if (zip)
         {
             var zipcontent = Zip7Helper.CompressLZMA(sUTF8NBOM.GetBytes(content));
             System.IO.File.WriteAllBytes(path, zipcontent);
         }
         else
         {
             System.IO.File.WriteAllText(path, content, new UTF8Encoding(false));
         }
     } catch (Exception exc) {
         return(false);
     }
     return(true);
 }