【打包工具】修复拷贝提示错误
parent
10deef53cf
commit
3e12b64118
|
@ -248,13 +248,17 @@ public class AutoPack : EditorWindow
|
|||
string to = toPath + dir;
|
||||
if (Directory.Exists(to)) Directory.Delete(to, true);
|
||||
Directory.CreateDirectory(to);
|
||||
GameCore.FileUtils.CopyDir(fromPath + dir, to);
|
||||
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
|
||||
|
||||
EditorUtility.DisplayProgressBar("重写AndroidManifest", "", 1f);
|
||||
EditorUtility.DisplayProgressBar("重写AndroidManifest", "", 0.5f);
|
||||
RewriteManifest(fromPath + "/src/main/AndroidManifest.xml", toPath + "/src/main/AndroidManifest.xml");
|
||||
Debug.Log(PackConfig[index][0] + ":母包Manifest修改完成");
|
||||
EditorUtility.ClearProgressBar();
|
||||
|
@ -306,14 +310,18 @@ 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);
|
||||
GameCore.FileUtils.CopyDir(ABPath, toPath, (string dirName, string fileName, float progress) =>
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("正在复制:" + dirName, fileName, progress);
|
||||
});
|
||||
EditorUtility.ClearProgressBar();
|
||||
Debug.Log(PackConfig[index][0] + ":替换AB包完成");
|
||||
}
|
||||
|
||||
// 替换配置文件
|
||||
private static void ReplaceConfigAndVersion(int index)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("替换配置文件", "", 1f);
|
||||
EditorUtility.DisplayProgressBar("替换配置文件", "", 0.5f);
|
||||
string toPath = _MomPackPath + PackConfig[index][2] + "/src/main/assets/Android/";
|
||||
string fromPath = _MomPackPath + PackConfig[index][2] + "/Config/";
|
||||
File.Copy(fromPath + ConfigFileName, toPath + ConfigFileName, true);
|
||||
|
@ -325,7 +333,7 @@ public class AutoPack : EditorWindow
|
|||
// 开始生成apk
|
||||
private static void StartGradleBuild(int index)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("正在生成APK", "", 1f);
|
||||
EditorUtility.DisplayProgressBar("正在生成APK", "", 0.5f);
|
||||
string apkPath = _MomPackPath + PackConfig[index][2] + "/APK/";
|
||||
if (!Directory.Exists(apkPath))
|
||||
{
|
||||
|
@ -338,7 +346,7 @@ public class AutoPack : EditorWindow
|
|||
}
|
||||
GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleRelease>" + apkPath + time +"/_log.txt");
|
||||
|
||||
EditorUtility.DisplayProgressBar("正在导出APK", "", 1f);
|
||||
EditorUtility.DisplayProgressBar("正在导出APK", "", 0.5f);
|
||||
string apkFilePath = _MomPackPath + PackConfig[index][2] + "/build/outputs/apk/release/" + PackConfig[index][2] + "-release.apk";
|
||||
if (File.Exists(apkFilePath))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
namespace GameCore {
|
||||
/// <summary>
|
||||
|
@ -81,7 +80,7 @@ namespace GameCore {
|
|||
/// </summary>
|
||||
/// <param name="fromDir"></param>
|
||||
/// <param name="toDir"></param>
|
||||
public static void CopyDir(string fromDir, string toDir)
|
||||
public static void CopyDir(string fromDir, string toDir, Action<string, string, float> callBack = null)
|
||||
{
|
||||
if (!Directory.Exists(fromDir))
|
||||
return;
|
||||
|
@ -97,15 +96,14 @@ namespace GameCore {
|
|||
string fileName = Path.GetFileName(formFileName);
|
||||
string toFileName = Path.Combine(toDir, fileName);
|
||||
File.Copy(formFileName, toFileName);
|
||||
EditorUtility.DisplayProgressBar("复制文件夹:"+fromDir, formFileName, (float)(++i / files.Length));
|
||||
if (callBack != null) callBack(fromDir, fileName, (float)++i/files.Length);
|
||||
}
|
||||
EditorUtility.ClearProgressBar();
|
||||
string[] fromDirs = Directory.GetDirectories(fromDir);
|
||||
foreach (string fromDirName in fromDirs)
|
||||
{
|
||||
string dirName = Path.GetFileName(fromDirName);
|
||||
string toDirName = Path.Combine(toDir, dirName);
|
||||
CopyDir(fromDirName, toDirName);
|
||||
CopyDir(fromDirName, toDirName, callBack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue