// 拷贝资源到 StreamingAssets 目录下 static void CopyAssetBundlesTo(string outputPath) { // Clear streaming assets folder. FileUtil.DeleteFileOrDirectory(Application.streamingAssetsPath); Directory.CreateDirectory(outputPath); string outputFolder = ExportUtil.GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget); // Setup the source folder for assetbundles. var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, ExportUtil.ASSET_BUNDLES_OUTPUT_PATH), outputFolder); if (!System.IO.Directory.Exists(source)) { Debug.Log("No assetBundle output folder, try to build the assetBundles first."); } // Setup the destination folder for assetbundles. var destination = System.IO.Path.Combine(outputPath, outputFolder); if (System.IO.Directory.Exists(destination)) { FileUtil.DeleteFileOrDirectory(destination); } FileUtil.CopyFileOrDirectory(source, destination); }
// 打包 Editor 的 Asset Labels 中指定的 AssetBundle public static void BuildAssetLabelsAssetBundles() { // Choose the output path according to the build target. string outputPath = Path.Combine(ExportUtil.ASSET_BUNDLES_OUTPUT_PATH, ExportUtil.GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget)); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } AssetBundleParam param = new AssetBundleParam(); param.m_pathName = outputPath; param.m_assetBundleOptions = 0; param.m_targetPlatform = EditorUserBuildSettings.activeBuildTarget; ExportUtil.BuildAssetBundle(param); }