private static void WriteMd5Record(Dictionary <string, string> value, string folderPath, Md5Record record) { if (record == null) { record = new Md5Record(); record.value = new Dictionary <string, List <string> >(); } string buildTarget = AssetPathHelper.GetBuildTarget(AssetPathHelper.GetBuildTarget()); List <string> tokenList = new List <string>(); foreach (string key in value.Keys) { tokenList.Add(key); tokenList.Add(value[key]); } if (record.value.Keys.Contains(buildTarget)) { record.value[buildTarget] = tokenList; } else { record.value.Add(buildTarget, tokenList); } string content = JsonMapper.ToJson(record); content = content.Replace("\"Assets/Things/", "\n\"Assets/Things/"); string path = GetMd5RecordPath(folderPath); WriteJson(content, path); }
private static Md5Record ReadMd5Record(string folderPath) { Md5Record record = null; string path = GetMd5RecordPath(folderPath); TextAsset jsonAsset = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)) as TextAsset; if (jsonAsset != null) { record = JsonMapper.ToObject <Md5Record>(jsonAsset.text); } return(record); }
public static bool IsFilesChanged(string folderPath) { Md5Record record = ReadMd5Record(folderPath); Dictionary <string, string> newValue = ComputeMd5(folderPath); Dictionary <string, string> oldValue = ReadMd5(record); bool isMd5Changed = IsMd5Changed(newValue, oldValue); if (isMd5Changed) { WriteMd5Record(newValue, folderPath, record); } return(isMd5Changed); }
/// <summary> /// 返回值 Key为资源路径,Value为资源Md5值,资源包括meta文件 /// </summary> /// <param name="folderPath"></param> /// <returns></returns> private static Dictionary <string, string> ReadMd5(Md5Record record) { Dictionary <string, string> result = new Dictionary <string, string>(); if (record != null) { string buildTarget = AssetPathHelper.GetBuildTarget(AssetPathHelper.GetBuildTarget()); if (record.value.Keys.Contains(buildTarget)) { List <string> tokenList = record.value[buildTarget]; for (int i = 0; i < tokenList.Count; i += 2) { result.Add(tokenList[i], tokenList[i + 1]); } } } return(result); }