// 编译原包 public static void BuildSrcApp() { // 拷贝Data包 PackAssetBundleUtlis.CopyFolder(string.Format("{0}/{0}", ResourceConst.PkgBundleFolder), "Assets/StreamingAssets"); AssetDatabase.Refresh(); string cur_dir = System.Environment.CurrentDirectory; string build_dir = ""; string app_name = ""; BuildTarget build_target = BuildTarget.StandaloneWindows64; BuildTargetGroup target_group = BuildTargetGroup.Standalone; string root_dir = ""; foreach (string arg in System.Environment.GetCommandLineArgs()) { if (arg.StartsWith("buildDir")) { root_dir = arg.Split('@')[1]; break; } #if UNITY_ANDROID root_dir = string.Format("{0}/build/android", System.IO.Directory.GetParent(cur_dir)); #elif UNITY_IPHONE root_dir = string.Format("{0}/build/ios", System.IO.Directory.GetParent(cur_dir)); #elif UNITY_STANDALONE_WIN root_dir = string.Format("{0}/build/pc", System.IO.Directory.GetParent(cur_dir)); #endif } #if UNITY_ANDROID build_dir = string.Format("{0}/{1}_{2}", root_dir, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HHmmss")); app_name = string.Format("{0}/{1}_{2}.apk", build_dir, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HHmmss")); build_target = BuildTarget.Android; #elif UNITY_IPHONE build_dir = string.Format("{0}/{1}_{2}", root_dir, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HHmmss")); app_name = string.Format("{0}/{1}_{2}.ipa", build_dir, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HHmmss")); build_target = BuildTarget.iOS; #elif UNITY_STANDALONE_WIN build_dir = string.Format("{0}/{1}_{2}", root_dir, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HHmmss")); app_name = string.Format("{0}/{1}_{2}.exe", build_dir, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HHmmss")); build_target = BuildTarget.StandaloneWindows64; #endif System.IO.Directory.CreateDirectory(build_dir); List <string> editor_scenes = new List <string>(); foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { if (!scene.enabled) { continue; } editor_scenes.Add(scene.path); } string[] scene_array = editor_scenes.ToArray(); EditorUserBuildSettings.SwitchActiveBuildTarget(build_target); //string res = BuildPipeline.BuildPlayer(scene_array, app_name, build_target, BuildOptions.None); }
static IEnumerator PackAllAssetBundleAsync(bool check) { string srcConfFolder = GetConf(); if (string.IsNullOrEmpty(srcConfFolder)) { yield break; } if (!Directory.Exists(ResourceConst.PkgBundleFolder)) { Directory.CreateDirectory(ResourceConst.PkgBundleFolder); } Clear(); DateTime dt1 = System.DateTime.UtcNow; // 分析场景; yield return(EditorCoroutineRunner.StartEditorCoroutine(DisposeSceneAsync())); DateTime dt2 = System.DateTime.UtcNow; yield return(EditorCoroutineRunner.StartEditorCoroutine(DisposeResourcesFolderAsync())); DateTime dt3 = System.DateTime.UtcNow; Build(); DateTime dt4 = System.DateTime.UtcNow; // 拷贝Conf; PackAssetBundleUtlis.CopyFolder(srcConfFolder, bundleBuildFolder); FileListUtility.BuildFileList(false); DateTime dt5 = System.DateTime.UtcNow; string confFolder = Path.GetFileName(srcConfFolder); PackAssetBundleUtlis.CopyAssetBundle(bundleBuildFolder, ResourceConst.PkgBundleFolder, confFolder); DateTime dt6 = System.DateTime.UtcNow; string info = string.Format("bundle打包完成\n总共{0}个文件\n耗时:{1}分钟\n其中:\n" , _packTools.Count, (dt6 - dt1).TotalMinutes.ToString("f1")); info = string.Format("{0}分析场景资源耗时:{1}秒\n", info, (dt2 - dt1).TotalSeconds.ToString("f1")); info = string.Format("{0}分析Resource资源耗时:{1}秒\n", info, (dt3 - dt2).TotalSeconds.ToString("f1")); info = string.Format("{0}打包AssetBundle耗时:{1}秒\n", info, (dt4 - dt3).TotalSeconds.ToString("f1")); info = string.Format("{0}生成FileList耗时:{1}秒\n", info, (dt5 - dt4).TotalSeconds.ToString("f1")); info = string.Format("{0}拷贝AssetBundle耗时:{1}秒\n", info, (dt6 - dt5).TotalSeconds.ToString("f1")); EditorUtility.DisplayDialog("打包完成", info, "好的"); if (check) { PackAssetBundleUtlis.CheckAllBundles(); } }
public static void CopyAssetBundle2StreamingAssets() { //string srcConfFolder = GetConf(); //if ( string.IsNullOrEmpty(srcConfFolder) ) //{ // return; //} //// 拷贝conf文件夹; //PackAssetBundleUtlis.CopyFolder(srcConfFolder, "Assets/StreamingAssets"); PackAssetBundleUtlis.CopyFolder(string.Format("{0}/{0}", ResourceConst.PkgBundleFolder), "Assets/StreamingAssets"); AssetDatabase.Refresh(); EditorUtility.DisplayDialog("拷贝完成", "拷贝完成", "好的"); }
public static void OnlyCopyConf2StreamingAssets() { string srcConfFolder = GetConf(); if (string.IsNullOrEmpty(srcConfFolder)) { return; } DateTime dt1 = System.DateTime.UtcNow; // 拷贝conf文件夹; PackAssetBundleUtlis.CopyFolder(srcConfFolder, string.Format("{0}", bundleBuildFolder)); PackAssetBundleUtlis.CopyFolder(srcConfFolder, string.Format("{0}", ResourceConst.BundleFolder)); DateTime dt2 = System.DateTime.UtcNow; bool result = FileListUtility.BuildFileListByConf(); DateTime dt3 = System.DateTime.UtcNow; //FileListUtility.BuildFileList(true); // 拷贝FileList文件; string fileList = string.Format("{0}/{1}", bundleBuildFolder, ResourceConst.FileListName); string newFileList = string.Format("{0}/{1}", ResourceConst.BundleFolder, ResourceConst.FileListName); PackAssetBundleUtlis.CopyFile(fileList, newFileList); GitUtility.PrintGitToData(); DateTime dt4 = System.DateTime.UtcNow; if (result) { string info = string.Format("Conf打包完成,总时长{0}秒", (dt4 - dt1).TotalSeconds.ToString("f1")); EditorUtility.DisplayDialog("打包完成", info, "好的"); } else { EditorUtility.DisplayDialog("打包失败", "Conf打包失败,详情请看Log!", "马上去看"); } }
public static void PackAllAssetBundle(bool check, bool tip_dialog = true) { string srcConfFolder = GetConf(tip_dialog); if (string.IsNullOrEmpty(srcConfFolder)) { return; } if (!Directory.Exists(ResourceConst.PkgBundleFolder)) { Directory.CreateDirectory(ResourceConst.PkgBundleFolder); } Clear(); DateTime dt1 = System.DateTime.UtcNow; // 分析场景; DisposeScene(); DateTime dt2 = System.DateTime.UtcNow; DisposeResourcesInfoFolder(); // 检查用到的Shader; if (!CheckShader()) { return; } DateTime dt3 = System.DateTime.UtcNow; Build(); DateTime dt4 = System.DateTime.UtcNow; // 拷贝Conf; PackAssetBundleUtlis.CopyFolder(srcConfFolder, bundleBuildFolder); FileListUtility.BuildFileList(false); GitUtility.PrintGitToData(); //GitUtility.PrintGitModifyDetailToData_2(); // 记录比较; string compareInfo = PackAssetBundleUtlis.CompareFileList(BundleUpdateMode.Update_CRC); string compareInfo2 = PackAssetBundleUtlis.CompareFileList(BundleUpdateMode.Update_MD5); string compareInfo3 = PackAssetBundleUtlis.CompareFileList(BundleUpdateMode.Update_CRCANDMD5); string compareInfo4 = PackAssetBundleUtlis.CompareFileList(BundleUpdateMode.Update_CRCORMD5); DateTime dt5 = System.DateTime.UtcNow; string confFolder = Path.GetFileName(srcConfFolder); PackAssetBundleUtlis.CopyAssetBundle(bundleBuildFolder, ResourceConst.PkgBundleFolder, confFolder); DateTime dt6 = System.DateTime.UtcNow; // BuildMiniFileList.Build(); DateTime dt7 = System.DateTime.UtcNow; // ExportMiniClient.Export(); DateTime dt8 = System.DateTime.UtcNow; string info = string.Format("bundle打包完成\n总共{0}个文件\n耗时:{1}分钟\n其中:\n" , _packTools.Count, (dt6 - dt1).TotalMinutes.ToString("f1")); info = string.Format("{0}分析场景资源耗时:{1}秒\n", info, (dt2 - dt1).TotalSeconds.ToString("f1")); info = string.Format("{0}分析Resource资源耗时:{1}秒\n", info, (dt3 - dt2).TotalSeconds.ToString("f1")); info = string.Format("{0}打包AssetBundle耗时:{1}秒\n", info, (dt4 - dt3).TotalSeconds.ToString("f1")); info = string.Format("{0}生成FileList耗时:{1}秒\n", info, (dt5 - dt4).TotalSeconds.ToString("f1")); info = string.Format("{0}拷贝AssetBundle耗时:{1}秒\n", info, (dt6 - dt5).TotalSeconds.ToString("f1")); info = string.Format("{0}生成FileList2耗时:{1}秒\n", info, (dt7 - dt6).TotalSeconds.ToString("f1")); info = string.Format("{0}导出微端资源耗时:{1}秒\n", info, (dt8 - dt7).TotalSeconds.ToString("f1")); info = string.Format("{0}\n{1}\n", info, compareInfo); info = string.Format("{0}\n{1}\n", info, compareInfo2); info = string.Format("{0}\n{1}\n", info, compareInfo3); info = string.Format("{0}\n{1}\n", info, compareInfo4); if (tip_dialog) { EditorUtility.DisplayDialog("打包完成", info, "好的"); } if (check) { PackAssetBundleUtlis.CheckAllBundles(tip_dialog); } }