/// <summary> /// 自动构建ab /// </summary> /// <param name="assets"></param> /// <param name="outPath"></param> /// <param name="abName"></param> /// <param name="bbo"></param> static public void BuildABs(AssetBundleBuild[] bab, string outPath, BuildAssetBundleOptions bbo) { if (string.IsNullOrEmpty(outPath)) { outPath = GetOutPutPath(); } string tmpPath = BuildScript.GetProjectTempPath(); ExportResources.CheckDirectory(tmpPath); BuildPipeline.BuildAssetBundles(tmpPath, bab, bbo, target); foreach (AssetBundleBuild abb in bab) { string abName = abb.assetBundleName; string tmpFileName = Path.Combine(tmpPath, abName); string targetFileName = Path.Combine(outPath, abName); FileInfo tInfo = new FileInfo(targetFileName); if (tInfo.Exists) { tInfo.Delete(); } FileInfo fino = new FileInfo(tmpFileName); fino.CopyTo(targetFileName); } }
/// <summary> /// 自动构建ab /// </summary> /// <param name="assets"></param> /// <param name="outPath"></param> /// <param name="abName"></param> /// <param name="bbo"></param> static public void BuildABs(string[] assets, string outPath, string abName, BuildAssetBundleOptions bbo) { AssetBundleBuild[] bab = new AssetBundleBuild[1]; bab[0].assetBundleName = abName;//打包的资源包名称 随便命名 bab[0].assetNames = assets; if (string.IsNullOrEmpty(outPath)) { outPath = GetOutPutPath(); } string tmpPath = BuildScript.GetProjectTempPath(); ExportResources.CheckDirectory(tmpPath); string tmpFileName = Path.Combine(tmpPath, abName); BuildPipeline.BuildAssetBundles(tmpPath, bab, bbo, target); string targetFileName = Path.Combine(outPath, abName); FileInfo tInfo = new FileInfo(targetFileName); if (tInfo.Exists) { tInfo.Delete(); } FileInfo fino = new FileInfo(tmpFileName); fino.CopyTo(targetFileName); }