ImportArtResTool.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. using UnityEditor;
  2. using UnityEngine;
  3. using System.IO;
  4. using System;
  5. using System.Collections.Generic;
  6. using ET;
  7. using GFGGame;
  8. namespace GFGEditor
  9. {
  10. public class ImportArtResTool
  11. {
  12. public static string ResRootDirName = "正式资源";
  13. public static string ResRootDirNameDressUp = "正式资源";
  14. public static string ResRootPath { get { return $"../../{ResRootDirName}/"; } }
  15. public static string ResRootPathDressUp { get { return $"../../{ResRootDirNameDressUp}/"; } }
  16. public static string ragule = @"^[0-9a-zA-Z_.]{1,}$";
  17. public static string Md5FilePath = $"{ResPathUtil.RES_ROOT_DIR_PATH}/MD5";
  18. private static string[] FieldGuideIconSrcPaths { get { return new string[] { ResRootPath + "图鉴/套装图鉴" }; } }
  19. public static string FieldGuideIconTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/FieldGuide/SuitIcon/";
  20. public static string FieldGuideIconMd5FileSaveName = "FieldGuideIconMd5";
  21. private static string[] ChapterGuideIconSrcPaths { get { return new string[] { ResRootPath + "图鉴/博物图鉴" }; } }
  22. public static string ChapterGuideIconTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/FieldGuide/ChapterIcon/";
  23. public static string ChapterGuideIconMd5FileSaveName = "ChapterGuideIconMd5";
  24. private static string[] StoryGuideIconSrcPaths { get { return new string[] { ResRootPath + "图鉴/故事图鉴" }; } }
  25. public static string StoryGuideIconTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/FieldGuide/ChapterIcon/";
  26. public static string StoryGuideIconMd5FileSaveName = "StoryGuideIconMd5";
  27. private static string[] MusicSrcPaths { get { return new string[] { ResRootPath + "music/" }; } }
  28. public static string MusicTargetPath = $"{ResPathUtil.MUSIC_DIR_PATH}/";
  29. public static string MusicMd5FileSaveName = "MusicMd5";
  30. private static string[] VoiceSrcPaths { get { return new string[] { ResRootPath + "voice/" }; } }
  31. public static string VoiceTargetPath = $"{ResPathUtil.Voice_DIR_PATH}/";
  32. public static string VoiceMd5FileSaveName = "VoiceMd5";
  33. private static string[] VideoSrcPaths { get { return new string[] { ResRootPath + "video/" }; } }
  34. public static string VideoTargetPath = $"{ResPathUtil.Voice_DIR_PATH}/";
  35. public static string VideoMd5FileSaveName = "VideoMd5";
  36. private static string[] CardMusicSrcPaths { get { return new string[] { ResRootPath + "cardMusic/Card/" }; } }
  37. public static string CardMusicTargetPath = $"{ResPathUtil.SOUND_DIR_PATH}/Card/";
  38. public static string CardMusicMd5FileSaveName = "CardMusicMd5";
  39. private static string[] ItemIconSrcPaths { get { return new string[] { ResRootPath + "icon/" }; } }
  40. public static string ItemIconTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Icon/";
  41. public static string IconMd5FileSaveName = "IconMd5";
  42. private static string[] DressUpSrcPaths { get { return new string[] { ResRootPathDressUp + "suit/" }; } }
  43. public static string DressUpTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/DressUp/";
  44. public static string DressUpMd5FileSaveName = "DressUpMd5";
  45. private static string[] NpcFaceSrcPaths { get { return new string[] { ResRootPath + "npc/对话表情/" }; } }
  46. public static string NpcFaceTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Npc/Face/";
  47. public static string NpcFacepMd5FileSaveName = "NpcFaceMd5";
  48. private static string[] NpcHeadSrcPaths { get { return new string[] { ResRootPath + "npc/对战头像/" }; } }
  49. public static string NpcHeadTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Npc/Head/";
  50. public static string NPCHeadMd5FileSaveName = "NpcHeadMd5";
  51. private static string[] NpcPicSrcPaths { get { return new string[] { ResRootPath + "npc/对战立绘/" }; } }
  52. public static string NpcPicTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Npc/PicF/";
  53. public static string PicFMd5FileSaveName = "PicFMd5";
  54. private static string[] NpcPicSSrcPaths { get { return new string[] { ResRootPath + "npc/对话立绘/" }; } }
  55. public static string NpcPicSTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Npc/PicS/";
  56. public static string PicSMd5FileSaveName = "PicSMd5";
  57. public static string[] BgSrcPaths { get { return new string[] { ResRootPath + "scene/" }; } }
  58. public static string BgTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/SceneBg/";
  59. public static string BgMd5FileSaveName = "BgMd5";
  60. private static string[] CardBgSrcPaths { get { return new string[] { ResRootPath + "卡牌/pic/" }; } }
  61. public static string CardBgTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Card/Bg/";
  62. public static string CardBgMd5FileSaveName = "CardBgMd5";
  63. private static string[] CardIconSrcPaths { get { return new string[] { ResRootPath + "卡牌/icon/" }; } }
  64. public static string CardIconTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Card/Card/";
  65. public static string CardMd5FileSaveName = "CardMd5";
  66. private static string[] CardSkillSrcPaths { get { return new string[] { ResRootPath + "卡牌/skill/" }; } }
  67. public static string CardSkillTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Card/Skill/";
  68. public static string CardSkillMd5FileSaveName = "CardSkillMd5";
  69. private static string[] ActivitySrcPaths { get { return new string[] { ResRootPath + "activity/activity/" }; } }
  70. public static string ActivityTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Activity/Activity/";
  71. public static string ActivityMd5FileSaveName = "ActivityMd5";
  72. private static string[] ActivityShow1SrcPaths { get { return new string[] { ResRootPath + "activity/show1/" }; } }
  73. public static string ActivityShow1TargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Activity/Show1/";
  74. public static string ActivityShow1Md5FileSaveName = "ActivityShow1Md5";
  75. private static string[] PhotoGraphBorderPaths { get { return new string[] { ResRootPath + "边框/" }; } }
  76. public static string PhotoGraphBorderTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Photograph/border/";
  77. public static string PhotoGraphBorderMd5FileSaveName = "PhotoGraphBorderMd5";
  78. private static string[] UIBgSrcPaths { get { return new string[] { ResRootPath + "UI背景/" }; } }
  79. public static string UIBgTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/BgImg/";
  80. public static string UIBgMd5FileSaveName = "UIBgMd5";
  81. private static string[] ActivityShow2SrcPaths { get { return new string[] { ResRootPath + "activity/show2/" }; } }
  82. public static string ActivityShow2TargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Activity/Show2/";
  83. public static string ActivityShow2Md5FileSaveName = "ActivityShow2Md5";
  84. public static string[] DressUpAnimationSrcPaths { get { return new string[] { ResRootPathDressUp + $"ArtProject/{ResPathUtil.ANIMATION_DIR_PATH}/" }; } }
  85. public static string DressUpAnimationTargetPath = $"{ResPathUtil.ANIMATION_DIR_PATH}/";
  86. public static string[] EffectSrcPaths { get { return new string[] { ResRootPath + $"ArtProject/{ResPathUtil.EFFECT_DIR_PATH}/" }; } }
  87. public static string EffectTargetPath = $"{ResPathUtil.EFFECT_DIR_PATH}/";
  88. public static string[] MaterialSrcPaths { get { return new string[] { ResRootPath + $"ArtProject/{ResPathUtil.Material_DIR_PATH}/Effect/" }; } }
  89. public static string MaterialTargetPath = $"{ResPathUtil.Material_DIR_PATH}/Effect/";
  90. public static string EffectMaterialMd5FileSaveName = "EffectMaterialMd5";
  91. public static string[] ShaderSrcPaths { get { return new string[] { ResRootPath + $"ArtProject/{ResPathUtil.Shader_DIR_PATH}/" }; } }
  92. public static string ShaderTargetPath = $"{ResPathUtil.Shader_DIR_PATH}/";
  93. public static string ShaderMd5FileSaveName = "ShaderMd5";
  94. public static string[] ModelSrcPaths { get { return new string[] { ResRootPath + $"ArtProject/{ResPathUtil.Model_DIR_PATH}/" }; } }
  95. public static string ModelTargetPath = $"{ResPathUtil.Model_DIR_PATH}/";
  96. public static string ModelMd5FileSaveName = "ModelMd5";
  97. public static string[] TextureSrcPaths { get { return new string[] { ResRootPath + $"ArtProject/{ResPathUtil.TEXTURE_DIR_PATH}/Effect/" }; } }
  98. public static string TextureTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Effect/";
  99. public static string EffectTextureMd5FileSaveName = "EffectTextureMd5";
  100. private static string[] TravelBgPaths { get { return new string[] { ResRootPath + "千山万水/背景/" }; } }
  101. public static string TravelBgTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Travel/Bg/";
  102. public static string TravelBgMd5FileSaveName = "TravelBgMd5";
  103. private static string[] TravelRolePaths { get { return new string[] { ResRootPath + "千山万水/角色/" }; } }
  104. public static string TravelRoleTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Travel/Role/";
  105. public static string TravelRoleMd5FileSaveName = "TravelRoleMd5";
  106. private static string[] HeadPaths { get { return new string[] { ResRootPath + "头像/头像/" }; } }
  107. public static string HeadTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Head/Head/";
  108. public static string HeadMd5FileSaveName = "HeadMd5";
  109. private static string[] HeadBorderPaths { get { return new string[] { ResRootPath + "头像/头像框/" }; } }
  110. public static string HeadBorderTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/Head/HeadBorder/";
  111. public static string HeadBorderMd5FileSaveName = "HeadBorderMd5";
  112. private static string[] LeagueIconPaths { get { return new string[] { ResRootPath + "联盟徽章/" }; } }
  113. public static string LeagueIconTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/LeagueIcon/";
  114. public static string LeagueIconMd5FileSaveName = "LeagueIconMd5";
  115. public static string[] MiniGameFlipPaths { get { return new string[] { ResRootPath + "MiniGame/FlipGame/" }; } }
  116. public static string MiniGameFlipTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/MiniGame/FlipGame/";
  117. public static string MiniGameFlipMd5FileSaveName = "MiniGameFlipMd5";
  118. public static string[] MiniGameHRDPaths { get { return new string[] { ResRootPath + "MiniGame/HRDGame/" }; } }
  119. public static string MiniGameHRDTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/MiniGame/HRDGame/";
  120. public static string MiniGameHRDMd5FileSaveName = "MiniGameHRDMd5";
  121. public static string[] MiniGameTZFEPaths { get { return new string[] { ResRootPath + "MiniGame/TZFEGame/" }; } }
  122. public static string MiniGameTZFETargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/MiniGame/TZFEGame/";
  123. public static string MiniGameTZFEMd5FileSaveName = "MiniGameTZFEMd5";
  124. public static string[] MiniGameMergePaths { get { return new string[] { ResRootPath + "MiniGame/MergeGame/" }; } }
  125. public static string MiniGameMergeTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/MiniGame/MergeGame/";
  126. public static string MiniGameMergeMd5FileSaveName = "MiniGameMergeMd5";
  127. public static string[] LuckyBoxTitleImgPaths { get { return new string[] { ResRootPath + "UI/LuckyBoxTitleImg/" }; } }
  128. public static string LuckyBoxTitleImgTargetPath = $"{ResPathUtil.TEXTURE_DIR_PATH}/LuckyBoxTitleImg/";
  129. public static string LuckyBoxTitleImgMd5FileSaveName = "LuckyBoxTitleImgMd5";
  130. public static void Test()
  131. {
  132. ImportClip(NpcFaceSrcPaths, NpcFaceTargetPath, NpcFacepMd5FileSaveName);
  133. }
  134. public static void Import()
  135. {
  136. var md5Path = ImportArtResTool.Md5FilePath;
  137. if (!Directory.Exists(md5Path))
  138. {
  139. Directory.CreateDirectory(md5Path);
  140. }
  141. //音乐
  142. EditorUtility.DisplayProgressBar("进度", "正在导入音乐", 1);
  143. ImportRes(MusicSrcPaths, MusicTargetPath, MusicMd5FileSaveName);
  144. //语音
  145. EditorUtility.DisplayProgressBar("进度", "正在导入语音", 1);
  146. ImportRes(VoiceSrcPaths, VoiceTargetPath, VoiceMd5FileSaveName);
  147. //视频
  148. EditorUtility.DisplayProgressBar("进度", "正在导入视频", 1);
  149. ImportRes(VideoSrcPaths, VideoTargetPath, VideoMd5FileSaveName);
  150. //词牌音乐
  151. EditorUtility.DisplayProgressBar("进度", "正在导入词牌音乐", 1);
  152. ImportRes(CardMusicSrcPaths, CardMusicTargetPath, CardMusicMd5FileSaveName);
  153. //套装图鉴图标
  154. EditorUtility.DisplayProgressBar("进度", "正在导入图鉴图标", 1);
  155. ImportRes(FieldGuideIconSrcPaths, FieldGuideIconTargetPath, FieldGuideIconMd5FileSaveName);
  156. //博物图鉴图标
  157. EditorUtility.DisplayProgressBar("进度", "正在导入博物图鉴图标", 1);
  158. ImportRes(ChapterGuideIconSrcPaths, ChapterGuideIconTargetPath, ChapterGuideIconMd5FileSaveName);
  159. //故事图鉴图标
  160. EditorUtility.DisplayProgressBar("进度", "正在导入故事图鉴图标", 1);
  161. ImportRes(StoryGuideIconSrcPaths, StoryGuideIconTargetPath, StoryGuideIconMd5FileSaveName);
  162. //物品图标
  163. EditorUtility.DisplayProgressBar("进度", "正在导入物品图标", 1);
  164. ImportRes(ItemIconSrcPaths, ItemIconTargetPath, IconMd5FileSaveName);
  165. // 换装部件
  166. EditorUtility.DisplayProgressBar("进度", "正在裁减换装部件", 1);
  167. ImportClip(DressUpSrcPaths, DressUpTargetPath, DressUpMd5FileSaveName);
  168. // NPC对话表情
  169. EditorUtility.DisplayProgressBar("进度", "正在裁减NPC对话表情", 1);
  170. ImportClip(NpcFaceSrcPaths, NpcFaceTargetPath, NpcFacepMd5FileSaveName);
  171. //NPC头像
  172. EditorUtility.DisplayProgressBar("进度", "正在导入NPC头像", 1);
  173. ImportRes(NpcHeadSrcPaths, NpcHeadTargetPath, NPCHeadMd5FileSaveName);
  174. //背景
  175. EditorUtility.DisplayProgressBar("进度", "正在导入背景图", 1);
  176. ImportRes(BgSrcPaths, BgTargetPath, BgMd5FileSaveName);
  177. //词牌背景
  178. EditorUtility.DisplayProgressBar("进度", "正在导入词牌背景", 1);
  179. ImportRes(CardBgSrcPaths, CardBgTargetPath, CardBgMd5FileSaveName);
  180. //词牌icon
  181. EditorUtility.DisplayProgressBar("进度", "正在导入词牌图标", 1);
  182. ImportRes(CardIconSrcPaths, CardIconTargetPath, CardMd5FileSaveName);
  183. //词牌技能图标
  184. EditorUtility.DisplayProgressBar("进度", "正在导入词牌技能图标", 1);
  185. ImportRes(CardSkillSrcPaths, CardSkillTargetPath, CardSkillMd5FileSaveName);
  186. //活动宣传图
  187. EditorUtility.DisplayProgressBar("进度", "正在导入活动宣传图", 1);
  188. ImportRes(ActivitySrcPaths, ActivityTargetPath, ActivityMd5FileSaveName);
  189. //活动展示图1
  190. EditorUtility.DisplayProgressBar("进度", "正在导入活动展示图1", 1);
  191. ImportRes(ActivityShow1SrcPaths, ActivityShow1TargetPath, ActivityShow1Md5FileSaveName);
  192. //活动展示图2
  193. EditorUtility.DisplayProgressBar("进度", "正在导入活动展示图2", 1);
  194. ImportRes(ActivityShow2SrcPaths, ActivityShow2TargetPath, ActivityShow2Md5FileSaveName);
  195. //拍照边框
  196. EditorUtility.DisplayProgressBar("进度", "正在导入词牌图标", 1);
  197. ImportRes(PhotoGraphBorderPaths, PhotoGraphBorderTargetPath, PhotoGraphBorderMd5FileSaveName);
  198. //UI背景
  199. EditorUtility.DisplayProgressBar("进度", "正在导入UI背景", 1);
  200. ImportRes(UIBgSrcPaths, UIBgTargetPath, UIBgMd5FileSaveName);
  201. EditorUtility.DisplayProgressBar("进度", "正在导入千山万水背景", 1);
  202. ImportRes(TravelBgPaths, TravelBgTargetPath, TravelBgMd5FileSaveName);
  203. EditorUtility.DisplayProgressBar("进度", "正在导入千山万水角色资源", 1);
  204. ImportRes(TravelRolePaths, TravelRoleTargetPath, TravelRoleMd5FileSaveName);
  205. EditorUtility.DisplayProgressBar("进度", "正在导入玩家头像资源", 1);
  206. ImportRes(HeadPaths, HeadTargetPath, HeadMd5FileSaveName);
  207. EditorUtility.DisplayProgressBar("进度", "正在导入玩家头像框资源", 1);
  208. ImportRes(HeadBorderPaths, HeadBorderTargetPath, HeadBorderMd5FileSaveName);
  209. EditorUtility.DisplayProgressBar("进度", "正在导入联盟徽章资源", 1);
  210. ImportRes(LeagueIconPaths, LeagueIconTargetPath, LeagueIconMd5FileSaveName);
  211. //清除冗余动画
  212. FileUtil.DeleteUnnecessaryAnimation(ImportArtResTool.DressUpAnimationTargetPath, ImportArtResTool.DressUpAnimationSrcPaths[0]);
  213. FileUtil.DeleteUnnecessaryAnimation(ImportArtResTool.EffectTargetPath, ImportArtResTool.EffectSrcPaths[0]);
  214. //动画
  215. EditorUtility.DisplayProgressBar("进度", "正在导入动作动画", 1);
  216. ImportFileAndDir(DressUpAnimationSrcPaths, DressUpAnimationTargetPath, new string[] { ".moc3" });
  217. //特效
  218. EditorUtility.DisplayProgressBar("进度", "正在导入特效动画", 1);
  219. ImportFileAndDir(EffectSrcPaths, EffectTargetPath);
  220. //材质
  221. EditorUtility.DisplayProgressBar("进度", "正在导入特效材质", 1);
  222. ImportRes(MaterialSrcPaths, MaterialTargetPath, EffectMaterialMd5FileSaveName);
  223. //Shader
  224. EditorUtility.DisplayProgressBar("进度", "正在导入Shader", 1);
  225. ImportRes(ShaderSrcPaths, ShaderTargetPath, ShaderMd5FileSaveName);
  226. //model
  227. EditorUtility.DisplayProgressBar("进度", "正在导入Mhader", 1);
  228. ImportRes(ModelSrcPaths, ModelTargetPath, ModelMd5FileSaveName);
  229. //图片
  230. EditorUtility.DisplayProgressBar("进度", "正在导入特效图片", 1);
  231. ImportRes(TextureSrcPaths, TextureTargetPath, EffectTextureMd5FileSaveName);
  232. //NPC对话立绘
  233. EditorUtility.DisplayProgressBar("进度", "正在导入NPC对话立绘", 1);
  234. List<string> files = ImportRes(NpcPicSSrcPaths, NpcPicSTargetPath, PicSMd5FileSaveName);
  235. //NPC对战立绘
  236. EditorUtility.DisplayProgressBar("进度", "正在导入NPC对战立绘", 1);
  237. files = ImportRes(NpcPicSrcPaths, NpcPicTargetPath, PicFMd5FileSaveName);
  238. if (files != null && files.Count > 0)
  239. {
  240. EditorUtility.DisplayDialog("提示", "有NPC立绘更新,需要设置坐标原点!", "OK", "");
  241. }
  242. //小游戏资源
  243. EditorUtility.DisplayProgressBar("进度", "正在导入小游戏资源", 1);
  244. ImportRes(MiniGameFlipPaths, MiniGameFlipTargetPath, MiniGameFlipMd5FileSaveName);
  245. EditorUtility.DisplayProgressBar("进度", "正在导入小游戏资源", 1);
  246. ImportRes(MiniGameHRDPaths, MiniGameHRDTargetPath, MiniGameHRDMd5FileSaveName);
  247. EditorUtility.DisplayProgressBar("进度", "正在导入小游戏资源", 1);
  248. ImportRes(MiniGameTZFEPaths, MiniGameTZFETargetPath, MiniGameTZFEMd5FileSaveName);
  249. EditorUtility.DisplayProgressBar("进度", "正在导入小游戏资源", 1);
  250. ImportRes(MiniGameMergePaths, MiniGameMergeTargetPath, MiniGameMergeMd5FileSaveName);
  251. //摘星标题资源
  252. EditorUtility.DisplayProgressBar("进度", "正在导入摘星标题资源", 1);
  253. ImportRes(LuckyBoxTitleImgPaths, LuckyBoxTitleImgTargetPath, LuckyBoxTitleImgMd5FileSaveName);
  254. EditorUtility.ClearProgressBar();
  255. AssetDatabase.Refresh();
  256. Debug.LogWarning("导入美术资源成功!");
  257. }
  258. public static List<string> ImportRes(string[] sourceDirs, string targetDir, string saveName)
  259. {
  260. List<string> files = null;
  261. if (!Directory.Exists(targetDir))
  262. {
  263. Directory.CreateDirectory(targetDir);
  264. }
  265. foreach (string dir in sourceDirs)
  266. {
  267. files = FileUtil.CopyFilesTo(dir, targetDir, saveName, new string[] { ".png", ".jpg", ".mp3", ".wav", ".meta", ".mat", ".shader", ".tga", ".FBX"}, ragule);
  268. foreach (var file in files)
  269. {
  270. Debug.LogFormat("更新{0}", file);
  271. }
  272. }
  273. return files;
  274. }
  275. public static void ImportClip(string[] sourceDirs, string targetDir, string md5FileName)
  276. {
  277. //换装部件
  278. if (!Directory.Exists(targetDir))
  279. {
  280. Directory.CreateDirectory(targetDir);
  281. }
  282. Dictionary<string, string> sourceImageMD5 = new Dictionary<string, string>();
  283. sourceImageMD5 = ImagesClip.ReadSourceImagesMD5(md5FileName);
  284. foreach (string dir in sourceDirs)
  285. {
  286. GFGEditor.FileUtil.ForeachFileInDir(dir, null, (string file) =>
  287. {
  288. string fileName = Path.GetFileName(file);
  289. if (fileName == "saveMD5" || !FileUtil.CheckStringByRegular(fileName, ragule))
  290. {
  291. return;
  292. }
  293. if (!File.Exists(targetDir + fileName) || !sourceImageMD5.ContainsKey(file) || sourceImageMD5[file] != FileUtil.md5file(file))
  294. {
  295. sourceImageMD5[file] = FileUtil.md5file(file);
  296. ImagesClip.CutImageWhitePart(file, targetDir, fileName);
  297. }
  298. });
  299. }
  300. ImagesClip.WriteSourceImagesMD5(sourceImageMD5, md5FileName);
  301. AssetDatabase.Refresh();
  302. }
  303. public static List<string> ImportFileAndDir(string[] sourceDirs, string targetDir, string[] excludeExtentions = null)
  304. {
  305. List<string> files = null;
  306. if (!Directory.Exists(targetDir))
  307. {
  308. Directory.CreateDirectory(targetDir);
  309. }
  310. foreach (string dir in sourceDirs)
  311. {
  312. files = FileUtil.CopyDirsAndFilesInSubDirTo(dir, targetDir, excludeExtentions, ragule);
  313. foreach (var file in files)
  314. {
  315. Debug.LogFormat("更新{0}", file);
  316. }
  317. }
  318. return files;
  319. }
  320. }
  321. }