static private void ReplaceOldGUIDRef(Dictionary <string, string> dic, string folder_path) { string[] fileName = Directory.GetFiles(folder_path, "*", SearchOption.AllDirectories); foreach (string filePath in fileName) { //Debug.Log(filePath); FileInfo fileInfo = new FileInfo(filePath); if (IsReplaceFileType(filePath)) { string contents = File.ReadAllText(filePath); //Debug.Log(contents); IEnumerable <string> guids = UtilGuids.GetGuids(contents); foreach (var item in guids) { if (dic.ContainsKey(item)) { contents = contents.Replace(item, dic[item]); Debug.Log(string.Format("=Success !=In {0}=\n old={1}\n new={2} ", fileInfo.Name, AssetDatabase.GUIDToAssetPath(item), (dic[item]))); } else { Debug.LogWarning("=Replace Fail != No Key Match :" + UtilGuids.GetFildNameByGUID(item)); } } WritePrefab(filePath, contents); } } }
static private void SetNewGUID2Meta(Dictionary <string, string> dic, string folder_path) { Dictionary <string, string> ret = new Dictionary <string, string>(); string[] fileName = Directory.GetFiles(folder_path, "*.meta", SearchOption.AllDirectories); foreach (string filePath in fileName) { string contents = File.ReadAllText(filePath); IEnumerable <string> get_guild_in_prefab = UtilGuids.GetGuids(contents); foreach (var item in get_guild_in_prefab) { if (dic.ContainsKey(item)) { contents = contents.Replace(item, dic[item]); WritePrefab(filePath, contents); } } } }