// 打包自己指定资源 public static void BuildCustomAssetBundles() { // Choose the output path according to the build target. string outputPath = ExportUtil.getStreamingDataPath(""); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } AssetBundleParam param = new AssetBundleParam(); param.m_buildList = new AssetBundleBuild[1]; param.m_buildList[0].assetBundleName = "TestExportPrefab"; param.m_buildList[0].assetBundleVariant = UtilApi.UNITY3D; param.m_buildList[0].assetNames = new string[1]; param.m_buildList[0].assetNames[0] = "Assets/TestAssets/TestPrefab.prefab"; // 这个目录一定要是 Assets 下面写,并且加上扩展名字 param.m_pathName = outputPath; param.m_assetBundleOptions = 0; param.m_targetPlatform = EditorUserBuildSettings.activeBuildTarget; ExportUtil.BuildAssetBundle(param); // 打包成 unity3d 后文件名字会变成小写,这里修改一下 UtilPath.modifyFileNameToCapital(outputPath, "TestExportPrefab"); }
// 打包 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); }
public static void BuildStreamedSceneAssetBundles() { // Choose the output path according to the build target. string outputPath = ExportUtil.getStreamingDataPath(""); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } string[] levels = ExportUtil.GetLevelsFromBuildSettings(); AssetBundleParam param = new AssetBundleParam(); param.m_buildList = new AssetBundleBuild[1]; param.m_buildList[0].assetBundleName = "TestExportScene"; param.m_buildList[0].assetBundleVariant = UtilApi.UNITY3D; param.m_buildList[0].assetNames = new string[1]; param.m_buildList[0].assetNames[0] = levels[3]; // 这个目录一定要是 Assets 下面写,并且加上扩展名字 param.m_pathName = outputPath; param.m_assetBundleOptions = 0; param.m_targetPlatform = EditorUserBuildSettings.activeBuildTarget; ExportUtil.BuildAssetBundle(param); }