public static void BuildDev() { if (!EditorUtility.DisplayDialog("", "是否开始打包?", "确定", "取消")) { Debug.Log("取消打包"); return; } if (EditorUtility.DisplayDialog("", "是否先设置Assetbundle名字", "确定", "取消")) { AutoSetAssetBundleName.Init(true); } EditorUtility.DisplayProgressBar("打包中", "打包中...", 0f); string[] outputPathArray = new string[] { "assetbundle/sprite/", "assetbundle/data/", "assetbundle/ui/", }; foreach (string outputPath in outputPathArray) { if (Directory.Exists(EditorConfig.GetoutputPath() + "/" + outputPath)) { Directory.Delete(outputPath, true); } Directory.CreateDirectory(outputPath); } BuildPipeline.BuildAssetBundles(EditorConfig.GetoutputPath(), BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); BuildDll(); EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); }
//拷贝manifest文件到指定的目录中 public static void CopyManifestToDevEnvirment() { string DestPath = EditorConfig.DevProjectDirRoot + "/StreamingAssets/" + EditorConfig.GetoutputPath(bFolderOnly: true) + "/" + EditorConfig.GetoutputPath(bFolderOnly: true); File.Copy(EditorConfig.GetoutputPath() + "/" + EditorConfig.GetoutputPath(bFolderOnly: true), DestPath, true); DestPath = EditorConfig.DevProjectDirRoot + "/StreamingAssets/" + EditorConfig.GetoutputPath(bFolderOnly: true) + "/" + EditorConfig.GetoutputPath(bFolderOnly: true) + ".manifest"; File.Copy(EditorConfig.GetoutputPath() + "/" + EditorConfig.GetoutputPath(bFolderOnly: true) + ".manifest", DestPath, true); }
//[MenuItem("武当剑工具/资源打包/拷贝/ Assetbundle 到开发环境(程序编程环境)", false, 3)] public static void CopyABResourceToDevEnvirment() { foreach (string folder in EditorConfig.FolderNames) { string DestPath = EditorConfig.DevProjectDirRoot + "/StreamingAssets/" + EditorConfig.GetoutputPath(bFolderOnly: true) + "/" + folder + "/"; string ResPath = EditorConfig.ABExportPath + EditorConfig.GetoutputPath(bFolderOnly: true) + "/" + folder; EditorConfig.CopyDir(ResPath, DestPath); } CopyManifestToDevEnvirment(); }
//[MenuItem("武当剑工具/资源打包/打包(预制件)", false, 10)] public static void BuildPrefab() { if (EditorUtility.DisplayDialog("", "是否先设置Assetbundle名字", "确定", "取消")) { AutoSetAssetBundleName.Init(); } EditorUtility.DisplayProgressBar("打包中", "打包中...", 0f); string outputPath = EditorConfig.GetoutputPath(); if (Directory.Exists(outputPath)) { Directory.Delete(outputPath, true); } Directory.CreateDirectory(outputPath); BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); }
/// <summary> /// 打包dll文件; 拷贝dll到指定环境下->生成md5文件 /// </summary> //[MenuItem("武当剑工具/资源打包/打包(DLL+MD5)")] public static void BuildDll() { BuildTarget target = EditorUserBuildSettings.activeBuildTarget; if (target == BuildTarget.Android) { /* * string dllPath = Directory.GetParent (Application.dataPath) + "/Library/ScriptAssemblies/Assembly-CSharp.dll"; * string destPath = EditorConfig.GetoutputPath () + "Assembly-CSharp.dll"; * File.Copy (dllPath, destPath, true);*/ BundleCommonTools.MakeResourcesMd5FilesAndCopy(bCopy: false); Debug.Log("Dll已经压缩, 当前平台: Android"); } else { BundleCommonTools.MakeResourcesMd5FilesAndCopy(bCopy: false); Debug.Log("Android 平台专用, Dll打包被取消, 当前平台: " + EditorConfig.GetoutputPath(true)); } }
//[MenuItem("武当剑工具/资源打包/生成MD5", false, 2)] public static void MakeResourcesMd5FilesAndCopy(bool bCopy = true) { paths.Clear(); files.Clear(); string resPath = EditorConfig.GetoutputPath(); string newFilePath = resPath + "/files.txt"; if (File.Exists(newFilePath)) { File.Delete(newFilePath); } paths.Clear(); files.Clear(); Recursive(resPath); FileStream fs = new FileStream(newFilePath, FileMode.CreateNew); StreamWriter sw = new StreamWriter(fs); for (int i = 0; i < files.Count; i++) { string file = files[i]; string ext = Path.GetExtension(file); if (file.EndsWith(".meta") || file.Contains(".DS_Store")) { continue; } string md5 = md5file(file); string value = file.Replace(resPath, string.Empty); sw.WriteLine(value + "|" + md5); } sw.Close(); fs.Close(); AssetDatabase.Refresh(); if (bCopy) { string DestPath = EditorConfig.DevProjectDirRoot + "/StreamingAssets/" + EditorConfig.GetoutputPath(bFolderOnly: true) + "/files.txt"; File.Copy(EditorConfig.GetoutputPath() + "files.txt", DestPath, true); } }
public static void BuildPalyer() { string outputPath = EditorConfig.GetoutputPath() + "scene/"; if (Directory.Exists(outputPath)) { Directory.Delete(outputPath, true); } Directory.CreateDirectory(outputPath); string fullPath = EditorConfig.ABSourceRoot + "scene/"; string[] scenes = Directory.GetFiles(fullPath, "*.unity", SearchOption.AllDirectories); foreach (string sce in scenes) { string[] splitScenes = sce.Split('/'); string[] fileS = splitScenes[splitScenes.Length - 1].Split('.'); string outputpath = outputPath + fileS[0] + ".unity3d"; Debug.Log(outputpath); BuildPipeline.BuildPlayer(new string[] { sce }, outputpath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.BuildAdditionalStreamedScenes); } AssetDatabase.Refresh(); }