static public T LoadJsonOnWinPath<T>(PathType path, string fileName)
{
string url = "";
if (path == PathType.StreamingAssetsPath)
{
url = Application.streamingAssetsPath + "/" + fileName;
Debug.Log("我是StreamingAssetsPath读取\n" + url);
}
else
{
url = Application.dataPath + "/" + fileName;
Debug.Log("我是NormalPath读取\n" + url);
}
if (!File.Exists(url))
{
Debug.LogWarning("path is null ! " + fileName);
return default(T);
}
StreamReader sr = new StreamReader(url);
string json = sr.ReadToEnd();
Debug.Log("json: " + json);
T result = default(T);
if (!string.IsNullOrEmpty(json))
{
result = JsonUtility.FromJson<T>(json);
}
sr.Close();
return result;
}