diff --git a/Assets/Editor/AutoPack.cs b/Assets/Editor/AutoPack.cs index 1b8a77bc27..da2354ef5c 100644 --- a/Assets/Editor/AutoPack.cs +++ b/Assets/Editor/AutoPack.cs @@ -295,7 +295,10 @@ public class AutoPack : EditorWindow static string[] ReplaceDir = new string[] { "/src/main/assets/Android", - "/src/main/assets/bin", + "/src/main/assets/bin" + }; + static string[] CopyDir = new string[] + { "/src/main/jniLibs" }; @@ -308,14 +311,22 @@ public class AutoPack : EditorWindow { string dir = ReplaceDir[i]; string to = toPath + dir; - if (Directory.Exists(to)) Directory.Delete(to, true); - Directory.CreateDirectory(to); - GameCore.FileUtils.CopyDir(fromPath + dir, to, (string dirName, string fileName, float progress)=> + GameCore.FileUtils.ReplaceDir(fromPath + dir, to, (string dirName, string fileName, float progress)=> { EditorUtility.DisplayProgressBar("正在复制:"+ dirName, fileName, progress); }); EditorUtility.ClearProgressBar(); } + for (int i = 0; i < CopyDir.Length; i++) + { + string dir = CopyDir[i]; + string to = toPath + dir; + GameCore.FileUtils.CopyDir(fromPath + dir, to, (string dirName, string fileName, float progress) => + { + EditorUtility.DisplayProgressBar("正在复制:" + dirName, fileName, progress); + }); + EditorUtility.ClearProgressBar(); + } Debug.Log(PackConfig[index][0] + ":母包工程资源替换完成"); // 替换build-id @@ -372,7 +383,7 @@ public class AutoPack : EditorWindow string toPath = _MomPackPath + PackConfig[index][2] + "/src/main/assets/Android"; if (Directory.Exists(toPath)) Directory.Delete(toPath, true); Directory.CreateDirectory(toPath); - GameCore.FileUtils.CopyDir(ABPath, toPath, (string dirName, string fileName, float progress) => + GameCore.FileUtils.ReplaceDir(ABPath, toPath, (string dirName, string fileName, float progress) => { EditorUtility.DisplayProgressBar("正在复制:" + dirName, fileName, progress); }); diff --git a/Assets/Scripts/Core/Core/Utils/FileUtils.cs b/Assets/Scripts/Core/Core/Utils/FileUtils.cs index f583598890..b85797eccb 100644 --- a/Assets/Scripts/Core/Core/Utils/FileUtils.cs +++ b/Assets/Scripts/Core/Core/Utils/FileUtils.cs @@ -76,11 +76,11 @@ namespace GameCore { } /// - /// 拷贝文件夹 + /// 替换文件夹 /// /// /// - public static void CopyDir(string fromDir, string toDir, Action callBack = null) + public static void ReplaceDir(string fromDir, string toDir, Action callBack = null) { if (!Directory.Exists(fromDir)) return; @@ -100,6 +100,37 @@ namespace GameCore { } string[] fromDirs = Directory.GetDirectories(fromDir); foreach (string fromDirName in fromDirs) + { + string dirName = Path.GetFileName(fromDirName); + string toDirName = Path.Combine(toDir, dirName); + ReplaceDir(fromDirName, toDirName, callBack); + } + } + + /// + /// 拷贝并覆盖文件夹 + /// + /// + /// + public static void CopyDir(string fromDir, string toDir, Action callBack = null) + { + if (!Directory.Exists(fromDir)) + return; + if (!Directory.Exists(toDir)) + { + Directory.CreateDirectory(toDir); + } + string[] files = Directory.GetFiles(fromDir); + int i = 0; + foreach (string formFileName in files) + { + string fileName = Path.GetFileName(formFileName); + string toFileName = Path.Combine(toDir, fileName); + File.Copy(formFileName, toFileName, true); + if (callBack != null) callBack(fromDir, fileName, (float)++i / files.Length); + } + string[] fromDirs = Directory.GetDirectories(fromDir); + foreach (string fromDirName in fromDirs) { string dirName = Path.GetFileName(fromDirName); string toDirName = Path.Combine(toDir, dirName); diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/FrameTool.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/FrameTool.cs index 10689a5519..c34dcafaad 100644 --- a/Assets/Scripts/Editor/GameEditor/FrameTool/FrameTool.cs +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/FrameTool.cs @@ -209,7 +209,7 @@ namespace GameEditor.FrameTool //Debug.LogError(streamingPath); if (Directory.Exists(streamingPath)) Directory.Delete(streamingPath,true); Directory.CreateDirectory(streamingPath); - FileUtils.CopyDir(exportPath, streamingPath); + FileUtils.ReplaceDir(exportPath, streamingPath); //CopyResourceFiles(); }