public void Save() { if (!Directory.Exists(CSMD5Path)) { Directory.CreateDirectory(CSMD5Path); } this.GUID = AssetDatabase.AssetPathToGUID(FilePath); this.MD5 = UtilTool.GetMD5String(this.StringBuilder.ToString()); this.NeedReimport = false; if (string.IsNullOrEmpty(this.GUID) || !File.Exists(CSMD5Path + this.GUID) || !File.Exists(this.FilePath) || File.ReadAllText(CSMD5Path + this.GUID) != this.MD5) { this.NeedReimport = true; UtilTool.WriteAllText(this.FilePath, this.StringBuilder.ToString()); } if (this.NeedReimport) { AssetDatabase.ImportAsset(this.FilePath); } this.GUID = AssetDatabase.AssetPathToGUID(this.FilePath); UtilTool.WriteAllText(CSMD5Path + this.GUID, this.MD5); }
public void UpdateCSFile(System.Action <string, float> rFeedback) { if (!Directory.Exists(CSMD5Path)) { Directory.CreateDirectory(CSMD5Path); } for (int nIndex = 0; nIndex < mCSInfo.Count; ++nIndex) { var rCSInfo = mCSInfo[nIndex]; if (null != rFeedback) { rFeedback(string.Format("Update {0}", rCSInfo.SavePath), (float)(nIndex + 1) / (float)mCSInfo.Count); } rCSInfo.GUID = AssetDatabase.AssetPathToGUID(rCSInfo.SavePath); rCSInfo.MD5 = UtilTool.GetMD5String(rCSInfo.Text); rCSInfo.NeedReimport = false; if (string.IsNullOrEmpty(rCSInfo.GUID) || !File.Exists(CSMD5Path + rCSInfo.GUID) || !File.Exists(rCSInfo.SavePath) || File.ReadAllText(CSMD5Path + rCSInfo.GUID) != rCSInfo.MD5) { rCSInfo.NeedReimport = true; WriteFile(rCSInfo.Text, rCSInfo.SavePath); } } for (int nIndex = 0; nIndex < mCSInfo.Count; ++nIndex) { var rCSInfo = mCSInfo[nIndex]; if (null != rFeedback) { rFeedback(string.Format("Import {0}", rCSInfo.SavePath), (float)(nIndex + 1) / (float)mCSInfo.Count); } if (rCSInfo.NeedReimport) { AssetDatabase.ImportAsset(rCSInfo.SavePath); } rCSInfo.GUID = AssetDatabase.AssetPathToGUID(rCSInfo.SavePath); WriteFile(rCSInfo.MD5, CSMD5Path + rCSInfo.GUID); } }