Convert existing AssetBundle code
To build your AssetBundles in an existing project with the Scriptable Build Pipeline (SBP) package, replace all calls to the BuildPipeline.BuildAssetBundles method with the CompatibilityBuildPipeline.BuildAssetBundles method.
Note: Some features supported in BuildPipeline aren't available in the CompatibilityBuildPipeline.
BuildPipeline and CompatibilityBuildPipeline features reference
The following table compares the features of the BuildPipeline with the CompatibilityBuildPipeline:
| Feature | BuildPipeline |
CompatibilityBuildPipeline |
|---|---|---|
| Build AssetBundles | Call the BuildPipeline.BuildAssetBundles method. |
Call the CompatibilityBuildPipeline.BuildAssetBundles method. |
| Incremental building | Uses IncrementalBuildHash and TypeTreeHash to determine what to rebuild. For more information about incremental building with AssetBundles, refer to Rebuilding assets incrementally. |
SBP implements incremental building with the BuildCache class. |
| Asset loading path | AssetBundles built with BuildPipeline can load an asset with any of the following:
|
AssetBundles built with SBP only support loading an asset by full path by default. For more information about how to load files by name instead of by full path, refer to Load files by name. |
| AssetBundle manifest | The BuildPipeline accesses manifest information with the AssetBundleManifest class. |
SBP accesses manifest file information with the CompatibilityAssetBundleManifest class. This class has the same API as the AssetBundleManifest class, with an additional method to get the CRC value for a bundle. |
| AssetBundle .manifest files | Builds performed with BuildPipeline.BuildAssetBundles output YAML-format files with the .manifest file extension that describe the content of each AssetBundle. |
SBP doesn't write .manifest files for individual AssetBundles. When CompatibilityBuildPipeline is used, SBP serializes the CompatibilityAssetBundleManifest object to a .manifest file with a name matching the build folder name. This file has similar, but not identical, content to the top level .manifest file that's generated by BuildPipeline.BuildAssetBundles. |
| Code stripping | Prevent Player builds from stripping out types that are only used in AssetBundles with BuildPlayerOptions.assetBundleManifestPath and the .manifest file generated by BuildPipeline.BuildAssetBundles. |
SBP can generate a link.xml file to achieve the same result. Use ContentPipeline.BuildAssetBundles to make your own BundleBuildParameters and set WriteLinkXML to true. |
| Build Report | The BuildPipeline generates a BuildReport file. |
SBP doesn't generate a BuildReport file. |
| AssetBundle variants | Get AssetBundle variants with AssetBundleManifest.GetAllAssetBundlesWithVariant. |
SBP doesn't support AssetBundle variants. |
| Build callbacks | Supports the following callbacks:
|
Supports the following callbacks:
IPreprocessBuildWithReport and IPostprocessBuildWithReport. |
Build AssetBundles with options
Configure build options for the CompatibilityBuildPipeline.BuildAssetBundles method with BuildAssetBundleOptions.
Options enabled by default
The CompatibilityBuildPipeline.BuildAssetBundles method enables the following options by default, and you can't disable them:
| Option | Notes |
|---|---|
DeterministicAssetBundle |
SBP builds deterministically. |
DisableLoadAssetByFileName |
SBP only allows loading assets by full path, which is case-sensitive, and not by file name. For example, you must pass the exact full path My/Example1/Example2/Asset.asset to load the asset at that path, and not just Asset or Asset.asset. |
DisableLoadAssetByFileNameWithExtension |
SBP only allows loading assets by full path, and not by file name plus extension. |
Supported options
The CompatibilityBuildPipeline.BuildAssetBundles method supports the following BuildAssetBundleOptions:
| Option | Notes |
|---|---|
UncompressedAssetBundle |
Identical to using BuildCompression.Uncompressed. |
DisableWriteTypeTree |
Identical to using ContentBuildFlags.DisableWriteTypeTree. |
ForceRebuildAssetBundle |
Identical to using IBuildParameters.UseCache = false;. |
AppendHashToAssetBundleName |
Identical to using IBundleBuildParameters.AppendHash = true;. |
ChunkBasedCompression |
Identical to using BuildCompression.LZ4. Note: This has always been LZ4HC in the Editor, and LZ4 if it was recompressed at Runtime. |
RecurseDependencies |
Sets NonRecursiveDependencies = false in CompatibilityBuildPipeline. |
The CompatibilityBuildPipeline.BuildAssetBundles method supports the following options, but they're not automatically converted. Use the proposed alternative to apply the corresponding build options:
| Option | Notes |
|---|---|
AssetBundleStripUnityVersion |
Use the IBuildParameters with ContentBuildFlags.StripUnityVersion instead. |
SuppressLoadableErrors |
Use the IBuildParameters with ContentBuildFlags.SuppressLoadableErrors instead. |
Unsupported options
The CompatibilityBuildPipeline.BuildAssetBundles method doesn’t support the following BuildAssetBundleOptions: