static void ExportResourceNoTrack() { // 保存ウィンドウのパネルを表示 string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // アクティブなセレクションに対してリソースファイルをビルド BuildPipeline.BuildAssetBundle( Selection.activeObject, Selection.objects, path); } }
static void ExportAsset() { //打开保存面板,选择保存路径 string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3D"); if (path.Length != 0) { //选择要保存的对象 Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); //对选择的对象 进行打包 BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.StandaloneWindows); } }
public static void Execute() { List <CharacterElement> characterElements = new List <CharacterElement>(); // As a CharacterElement needs the name of the assetbundle // that contains its assets, we go through all assetbundles // to match them to the materials we find. string[] assetbundles = Directory.GetFiles(CreateAssetbundles.AssetbundlePath); string[] materials = Directory.GetFiles("Assets/characters", "*.mat", SearchOption.AllDirectories); foreach (string material in materials) { foreach (string bundle in assetbundles) { FileInfo bundleFI = new FileInfo(bundle); FileInfo materialFI = new FileInfo(material); string bundleName = bundleFI.Name.Replace(".assetbundle", ""); if (!materialFI.Name.StartsWith(bundleName)) { continue; } if (!material.Contains("Per Texture Materials")) { continue; } characterElements.Add(new CharacterElement(materialFI.Name.Replace(".mat", ""), bundleFI.Name)); break; } } // After collecting all CharacterElements we store them in an // assetbundle using a ScriptableObject. // Create a ScriptableObject that contains the list of CharacterElements. CharacterElementHolder t = new CharacterElementHolder(characterElements); // Save the ScriptableObject and load the resulting asset so it can // be added to an assetbundle. string p = "Assets/CharacterElementDatabase.asset"; AssetDatabase.CreateAsset(t, p); Object o = AssetDatabase.LoadAssetAtPath(p, typeof(CharacterElementHolder)); // Build the CharacterElementDatabase assetbundle. BuildPipeline.BuildAssetBundle(o, null, CreateAssetbundles.AssetbundlePath + "CharacterElementDatabase.assetbundle"); // Delete the ScriptableObject. AssetDatabase.DeleteAsset(p); Debug.Log("******* Updated Character Element Database, added " + characterElements.Count + " elements *******"); }
public static void Build(Object mainAsset, Object[] assets, string bundlePath, bool isLeaf = false) { BuildAssetBundleOptions buildOption = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.DeterministicAssetBundle; if (isLeaf) { buildOption |= BuildAssetBundleOptions.CompleteAssets; } BuildPipeline.BuildAssetBundle(mainAsset, assets, bundlePath, buildOption, EditorUserBuildSettings.activeBuildTarget); }
private static void CreateMultipleAssetBundle() { if (Selection.objects.Length > 0) { //显示保存窗口 string path = EditorUtility.SaveFilePanel("Create Multiple AssetBundle:", "", "New AssetBundle", "assetbundle"); if (path.Length > 0) { //打包 BuildPipeline.BuildAssetBundle(null, Selection.objects, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BUILD_TARGET); } } }
static void ExportResource() { // Bring up save panel string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, EditorUserBuildSettings.activeBuildTarget); Selection.objects = selection; } }
public static void Build(UnityEngine.Object obj, string path, string name, BuildTarget target) { if (!Directory.Exists(path)) { EditorUtility.DisplayDialog("提示", "不存在路径", "确定"); } else { BuildPipeline.BuildAssetBundle(obj, null, path + "/" + name + ".assetbundle", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, target); EditorUtility.DisplayDialog("提示", "打包完成", "提示"); } }
static void BuildCsv() { string applicationPath = Application.dataPath; string saveDir = applicationPath + "/StreamingAssets/"; string savePath = saveDir + "csv.assetbundle"; Object[] selections = Selection.GetFiltered(typeof(object), SelectionMode.DeepAssets); List <Object> outs = new List <Object> (); for (int i = 0, max = selections.Length; i < max; i++) { Object obj = selections[i]; //asset path:short path to the asset folder string fileAssetPath = AssetDatabase.GetAssetPath(obj); //check the prefix if (fileAssetPath.Substring(fileAssetPath.LastIndexOf('.') + 1) != "csv") { continue; } // string fileWholePath = applicationPath + "/" + fileAssetPath.Substring(fileAssetPath.IndexOf("/")); // soCsv csv = ScriptableObject.CreateInstance <soCsv>(); csv.fileName = obj.name; csv.content = File.ReadAllBytes(fileWholePath); //does this read and write is neccessarily string assetPathTemp = "Assets/Resources_Local/Temp/" + obj.name + ".asset"; AssetDatabase.CreateAsset(csv, assetPathTemp); Object outObj = AssetDatabase.LoadAssetAtPath(assetPathTemp, typeof(soCsv)); // Debug.Log("package : " + outObj.name); outs.Add(outObj); } Object[] outObjs = outs.ToArray(); if (BuildPipeline.BuildAssetBundle(null, outs.ToArray(), savePath, BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android)) { EditorUtility.DisplayDialog("ok", "build" + savePath + "success, length = " + outObjs.Length, "ok"); } else { Debug.LogWarning("build" + savePath + "failed"); } AssetDatabase.Refresh(); }
void BuildSelectDir() { if (null == Selection.activeObject) { return; } // Relative the Assets directory string selectPath = AssetDatabase.GetAssetPath(Selection.activeObject); Debug.Log("Select folder is " + selectPath); if (!string.IsNullOrEmpty(selectPath) && GfanTools.Utils.IsDirectory(selectPath)) { string[] fileEnts = GetFileNames(selectPath, true, "*.*"); UnityEngine.Object[] objs = GetAssets(fileEnts); foreach (Object obj in objs) { BuildPipeline.PushAssetDependencies(); BuildAssetBundleOptions opts = BuildAssetBundleOptions.CompleteAssets; foreach (BuildAssetBundleOptions op in buildOptions) { opts |= op; } BuildPipeline.BuildAssetBundle(obj, null, "AssetBundles/" + obj.name + ".unityBundle", opts, buildTarget); BuildPipeline.PopAssetDependencies(); // BuildPipeline.BuildPlayer(scenePath, path, buildTarget, BuildOptions.BuildAdditionalStreamedScenes); } // int npos = selectPath.LastIndexOf("/"); // // string fileName = selectPath.Substring(npos + 1, selectPath.Length - npos - 1); // Debug.Log("Select fileName is " + fileName); // // // bool searchChildren = true; // string[] fileEnts = Directory.GetFiles(selectPath, SearchOption.AllDirectories); // foreach (string file in fileEnts) // { // file = file.Replace("\\", "/"); // int pos = file.LastIndexOf("/"); // file = file.Substring(pos + 1, file.Length - pos - 1); // string localPath = "Assets/" + file; // Object obj = AssetDatabase.LoadMainAssetAtPath(localPath); // } } }
public void WriteBundle(BuildAssetBundleOptions options, BuildTarget target, string bundleDir) { string bundleStreamPath = string.Format("{0}/{1}.ab", Application.streamingAssetsPath, bundleName); string bundlePath = string.Format("{0}/{1}.ab", bundleDir, bundleName); Debug.Log(string.Format("Building {0}", bundleShortName)); if (node.isIndependent && !node.hasChild) { BuildPipeline.PushAssetDependencies(); } uint crc = 0; if (!string.IsNullOrEmpty(mainAsset)) { if (mainAsset.EndsWith(".unity")) { BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { mainAsset }, bundleStreamPath, target, out crc, BuildOptions.UncompressedAssetBundle); } else { BuildPipeline.BuildAssetBundle(AssetDatabase.LoadMainAssetAtPath(mainAsset), null, bundleStreamPath, out crc, options, target); } } else { List <Object> objs = new List <Object>(); assets.ForEach(a => objs.Add(AssetDatabase.LoadMainAssetAtPath(a))); if (objs.Count == 0) { Debug.LogError(string.Format("No assets found for the asset bundle: {0}", bundleShortName)); return; } BuildPipeline.BuildAssetBundle(null, objs.ToArray(), bundleStreamPath, out crc, options, target); } if (node.isIndependent && !node.hasChild) { BuildPipeline.PopAssetDependencies(); } bundleCRC = crc.ToString(); LZMAUtil.CompressFile(bundleStreamPath, bundlePath); FileInfo fi = new FileInfo(bundlePath); size = fi.Length; }
static void ExportResourceNoTrack() { // Bring up save panel Object[] ResourceName = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (Object o in ResourceName) { string Name = o.name; string path = EditorUtility.SaveFilePanel("Save Resource", "D:\\Project\\Base\\Assets\\AssetBundles\\Android", Name, "unity3d"); if (path.Length != 0) { BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android); } } }
static void ExportResourceRGB2() { // 打开保存面板,获得用户选择的路径 Debug.Log("路径是 : " + Application.streamingAssetsPath); Object obj = AssetDatabase.LoadMainAssetAtPath("Assets/YF_Prefabs/ChenyunStatus.prefab"); if (obj != null) { BuildPipeline.BuildAssetBundle(obj, null, Application.streamingAssetsPath + "/Test.assetbundle", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.StandaloneWindows); } }
static void ExportResource(Object[] objs, string path) { BuildTarget target = #if UNITY_ANDROID BuildTarget.Android; #elif UNITY_IPHONE BuildTarget.iPhone; #else BuildTarget.StandaloneWindows; #endif BuildAssetBundleOptions options = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets; BuildPipeline.BuildAssetBundle(null, objs, path, options, target); }
// 打包数据到bundle data // private static void CreateBundle(Object dataObj, string szBundleFile) { // 调试用,生成的asset数据用于检查打包数据是否成功 // AssetDatabase.CreateAsset(dataObj, "Assets/StreamingAssets/DataFolder/" + szBundleFile + ".asset"); // 打包数据 // #if UNITY_ANDROID BuildPipeline.BuildAssetBundle(dataObj, null, "Assets/StreamingAssets/Android/" + szBundleFile + ".assetbundle", BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android); #elif UNITY_IPHONE BuildPipeline.BuildAssetBundle(dataObj, null, "Assets/StreamingAssets/IOS/" + szBundleFile + ".assetbundle", BuildAssetBundleOptions.CollectDependencies, BuildTarget.iOS); #elif UNITY_STANDALONE_WIN || UNITY_EDITOR BuildPipeline.BuildAssetBundle(dataObj, null, "Assets/StreamingAssets/PC/" + szBundleFile + ".assetbundle", BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows); #endif AssetDatabase.Refresh(); }
static void ExportResource() { // 保存ウィンドウのパネルを表示 string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // アクティブなセレクションに対してリソースファイルをビルド Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); Selection.objects = selection; } }
static public void BuildAssetBundle(AssetBundleParam param) { #if UNITY_5 if (param.m_buildList != null) { BuildPipeline.BuildAssetBundles(param.m_pathName, param.m_buildList, param.m_assetBundleOptions, param.m_targetPlatform); } else { BuildPipeline.BuildAssetBundles(param.m_pathName, param.m_assetBundleOptions, param.m_targetPlatform); } #elif UNITY_4_6 || UNITY_4_5 BuildPipeline.BuildAssetBundle(param.m_mainAsset, param.m_assets, param.m_pathName, param.m_assetBundleOptions, param.m_targetPlatform); #endif }
//output multy files public static void BuildMultAsset(BuildTarget target) { string path = AssetbundleEditor.selectPath; if (path.Length != 0) { UnityEngine.Object[] selections = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets); foreach (var item in selections) { Debug.Log("se: " + item.name); BuildPipeline.BuildAssetBundle(item, null, path + "/" + item.name + ".assetbundle", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, target); } } }
static void ExportResource() { Debug.Log(Selection.activeObject.name); string path = "Assets/AssetBundles/" + Selection.activeObject.name + ".unity3d"; Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (var c in selection) { Debug.Log(c.name); } BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.WebGL); // BuildPipeline.BuildAssetBundles("Assets/AssetBundles", BuildAssetBundleOptions.None, BuildTarget.WebGL); }
//1.create temp prefab //2.fill the temp prefab //3.export temp prefab //4.delete temp prefab public static bool BuildAssetBundle(GameObject mainAsset, string pathName) { UnityEngine.Object tempPrefab = EditorUtility.CreateEmptyPrefab("Assets/" + mainAsset.name + ".prefab"); tempPrefab = EditorUtility.ReplacePrefab(mainAsset, tempPrefab); bool rtn = BuildPipeline.BuildAssetBundle(tempPrefab, null, pathName, BuildAssetBundleOptions.CollectDependencies, BuildTarget.WebPlayer); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(tempPrefab)); return(rtn); }
static void AndroBuilding() { Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); if (selection.Length <= 0) { return; } string path = EditorUtility.SaveFilePanel("另存为", Application.streamingAssetsPath + "/data", selection[0].name, "dat"); if (path.Length != 0) { BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android); Debug.Log("Android .dat文件导出完成"); } }
static void BuildCsv() { string applicationPath = Application.dataPath; string saveDir = applicationPath + "/StreamingAssets/"; string savePath = saveDir + "csv.assetbundle"; Object[] selections = Selection.GetFiltered(typeof(object), SelectionMode.DeepAssets); List <Object> outs = new List <Object>(); for (int i = 0, max = selections.Length; i < max; i++) { Object obj = selections[i]; string fileAssetPath = AssetDatabase.GetAssetPath(obj); if (fileAssetPath.Substring(fileAssetPath.LastIndexOf(".") + 1) != "csv") { continue; } string fileWholePath = applicationPath + "/" + fileAssetPath.Substring(fileAssetPath.IndexOf("/"));//总路径 soCsv csv = ScriptableObject.CreateInstance <soCsv>(); csv.fileName = obj.name; csv.content = File.ReadAllBytes(fileWholePath); string assetPathTemp = "Assets/Resource_Local/Temp/" + obj.name + ".asset"; AssetDatabase.CreateAsset(csv, assetPathTemp); Object outObj = AssetDatabase.LoadAssetAtPath(assetPathTemp, typeof(soCsv)); Debug.Log("package: " + outObj.name); outs.Add(outObj); } Object[] outObjs = outs.ToArray(); //BuildAssetBundleOptions.CollectDependencies相关联的内容都打包进去/CompleteAssets把整个包打在一起,5.0默认enable //UncompressedAssetBundle不压缩的打包,读取快,包比较大、DisableWriteTypeTree打包小,查找慢、DeterministicAssetBundle自定义打包方式,用不到 if (BuildPipeline.BuildAssetBundle(null, outs.ToArray(), savePath, BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android)) { EditorUtility.DisplayDialog("OK", "build" + savePath + "success,length=" + outObjs.Length, "OK"); } else { Debug.LogWarning("Build" + savePath + "failed"); } AssetDatabase.Refresh(); }
public static void BuildSoundPrefabResource(BuildTarget target) { if (File.Exists("c:/luaframework/files.txt")) { File.Delete("c:/luaframework/files.txt"); } AssetDatabase.Refresh(); Object mainAsset = null; string assetfile = string.Empty; BuildAssetBundleOptions options = BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.DeterministicAssetBundle; string assetPath = AppDataPath + "/StreamingAssets/game/AssetBounld/"; string prefabPaths = AppDataPath + "/LuaFramework/game/saveassert/Sound"; paths.Clear(); files.Clear(); string luaDataPath = prefabPaths.ToLower(); Recursive(luaDataPath); foreach (string f in files) { if (!f.EndsWith(".mp3")) { continue; } string head = AppDataPath + "/luaframework/game/"; string asseturl = f.Replace(head, ""); string BounldName = f.Remove(0, f.LastIndexOf("/") + 1); string assetBounldName = BounldName.Remove(BounldName.LastIndexOf(".")); if (Directory.Exists("c:/luaframework/game/AssetBounld/" + assetBounldName.ToLower() + ".unity3d")) { Directory.Delete("c:/luaframework/game/AssetBounld/" + assetBounldName.ToLower() + ".unity3d", true); } string streamPath = Application.streamingAssetsPath + "/game/AssetBounld/" + assetBounldName.ToLower() + ".unity3d"; if (Directory.Exists(streamPath)) { Directory.Delete(streamPath, true); } mainAsset = LoadAsset(asseturl); UnityEngine.Debug.Log(assetBounldName); assetfile = assetPath + assetBounldName.ToLower() + AppConst.ExtName; BuildPipeline.BuildAssetBundle(mainAsset, null, assetfile, options, target); } BuildFileIndex(); AssetDatabase.Refresh(); }
private void BuildAssetBundle(string groupFolder) { string outputPath = CombinePath( lhBundleBuilder.GetApplicationPath(), lhBundleBuilder.buildParameter.outputRootFolder, lhBundleBuilder.buildParameter.buildTarget.ToString(), groupFolder, bundleName + lhBundleBuilder.buildParameter.stuff ); FileInfo fileInfo = new FileInfo(outputPath); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } uint crc = lhBundleBuilder.buildParameter.crc; BuildAssetBundleOptions options = lhBundleBuilder.buildParameter.buildAssetBundleOptions; BuildTarget target = lhBundleBuilder.buildParameter.buildTarget; // Load all of assets in this bundle List <UnityEngine.Object> assets = new List <UnityEngine.Object>(); foreach (var include in includeList) { if (mainAsset.path.Equals(include)) { continue; } UnityEngine.Object[] assetsAtPath = AssetDatabase.LoadAllAssetsAtPath(include.path); if (assetsAtPath != null || assetsAtPath.Length != 0) { assets.AddRange(assetsAtPath); } else { Debug.LogError("LaoHan:Cannnot load [" + include + "] as asset object"); } } UnityEngine.Object main = AssetDatabase.LoadAssetAtPath(mainAsset.path, typeof(UnityEngine.Object)); bool succeed = BuildPipeline.BuildAssetBundle(main, assets.ToArray(), outputPath, out crc, options, target); //return succeed; }
public override void In(string groupkey, List <AssetGraph.AssetInfo> source, string recommendedBundleOutputDir) { var textureAssetPath = source[0].assetPath; var textureAssetType = source[0].assetType; var mainResourceTexture = AssetDatabase.LoadAssetAtPath(textureAssetPath, textureAssetType) as Texture2D; if (mainResourceTexture) { Debug.Log("SampleBundlizer_0:loaded:" + textureAssetPath); } else { Debug.LogError("SampleBundlizer_0:failed to load:" + textureAssetPath); } // load other resources. var subResources = new List <UnityEngine.Object>(); uint crc = 0; /** * generate AssetBundle for iOS */ var targetPath = Path.Combine(recommendedBundleOutputDir, "bundle.assetbundle"); try { BuildPipeline.BuildAssetBundle( mainResourceTexture, subResources.ToArray(), targetPath, out crc, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iOS ); } catch (Exception e) { Debug.Log("SampleBundlizer_0:e:" + e); } if (File.Exists(targetPath)) { Debug.Log("SampleBundlizer_0:generated recommendedBundleOutputDir:" + targetPath); } else { Debug.LogError("SampleBundlizer_0:asset bundle was not generated! recommendedBundleOutputDir:" + targetPath); } }
static void ExportResource() { // Bring up save panel string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // include the following Graphic APIs PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows, new GraphicsDeviceType[] { GraphicsDeviceType.Direct3D11, GraphicsDeviceType.OpenGLCore, GraphicsDeviceType.Vulkan }); // Build the resource file from the active selection. Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.StandaloneWindows); Selection.objects = selection; } }
static void BuildAssetBundle(List <string> datas) { BuildAssetBundleOptions opts = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle; string targetPath = null; foreach (string str in datas) { targetPath = str.Replace("Assets", "MogoResourcesOSX") + ".u"; targetPath = targetPath.Substring(0, targetPath.LastIndexOf("/")); targetPath.ExsitOrCreate(); BuildPipeline.BuildAssetBundle(AssetDatabase.LoadMainAssetAtPath(str), null, str.Replace("Assets", "MogoResourcesOSX") + ".u", opts, EditorUserBuildSettings.activeBuildTarget); } }
static void ExportSingle() { //获取选择的物体 Object[] objs = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); if (objs.Length < 0) { return; } //打包 foreach (Object obj in objs) { string savePath = ExportPath + ((GameObject)obj).name + ".unity3d"; BuildPipeline.BuildAssetBundle(obj, null, savePath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); AssetDatabase.Refresh(); } }
static void BuildSharedAssetBundle(string path, Object[] resources) { #if UNITY_5_3 #else FileManager.CreateDirectory(System.IO.Path.GetDirectoryName(path)); if (BuildPipeline.BuildAssetBundle(null, resources, path, _buildOptions, _buildTarget)) { Debug.Log(path + "资源打包成功"); } else { Debug.Log(path + "资源打包失败"); } #endif }
public static void ExecuteAll(string filePath, UnityEditor.BuildTarget target) { //清空一下缓存 Caching.CleanCache(); if (filePath.Length != 0) { Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(null, SelectedAsset, filePath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, target); } AssetDatabase.Refresh(); }
private void BuildPipeLine(string path, string childPath, Object[] objs, BuildTarget buildTarget) { string fullPath = path + childPath; System.IO.Directory.CreateDirectory(fullPath); var options = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets; BuildPipeline.PushAssetDependencies(); foreach (Object obj in objs) { BuildPipeline.BuildAssetBundle(obj, null, fullPath + obj.name + ".unity3d", options, buildTarget); } BuildPipeline.PopAssetDependencies(); }