【打包工具】优化Android出包时替换文件夹导致部分.so文件被删除的问题
parent
627954ae3f
commit
d0249ac5f0
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -76,11 +76,11 @@ namespace GameCore {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝文件夹
|
||||
/// 替换文件夹
|
||||
/// </summary>
|
||||
/// <param name="fromDir"></param>
|
||||
/// <param name="toDir"></param>
|
||||
public static void CopyDir(string fromDir, string toDir, Action<string, string, float> callBack = null)
|
||||
public static void ReplaceDir(string fromDir, string toDir, Action<string, string, float> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝并覆盖文件夹
|
||||
/// </summary>
|
||||
/// <param name="fromDir"></param>
|
||||
/// <param name="toDir"></param>
|
||||
public static void CopyDir(string fromDir, string toDir, Action<string, string, float> 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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue