管理类:
using LitJson;
using System;
using System.IO;
using UnityEngine;
public class LitJsonMgr
{
public static LitJsonMgr Instance = new LitJsonMgr();
private LitJsonMgr()
{
}
public bool WriteStringToFile(string fullPath, string data)
{
try
{
string directoryName = Path.GetDirectoryName(fullPath);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
File.WriteAllText(fullPath, data);
return true;
}
catch (Exception ex)
{
Debug.LogError(string.Format("WriteStringToFile fail, file=[{0}], Exception msg:[{1}]", fullPath, ex.ToString()));
return false;
}
}
public bool WriteToFile(string fullPath, JsonData data)
{
return WriteStringToFile(fullPath, data.ToJson());
}
publ