Version: 2022.1
LanguageEnglish
  • C#

BuildPipeline.BuildAssetBundle

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete BuildAssetBundle has been made obsolete. Please use the new AssetBundle build system introduced in 5.0 and check BuildAssetBundles documentation for details.

Declaration

public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform);
Obsolete BuildAssetBundle has been made obsolete. Please use the new AssetBundle build system introduced in 5.0 and check BuildAssetBundles documentation for details.

Declaration

public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, out uint crc, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform);

Parameters

mainAsset Lets you specify a specific object that can be conveniently retrieved using AssetBundle.mainAsset.
assets An array of assets to write into the bundle.
pathName The filename where to write the compressed asset bundle.
assetBundleOptions Automatically include dependencies or always include complete assets instead of just the exact referenced objects.
targetPlatform The platform to build the bundle for.
crc The optional crc output parameter can be used to get a CRC checksum for the generated AssetBundle, which can be used to verify content when downloading AssetBundles using UnityWebRequestAssetBundle.GetAssetBundle.

Description

Builds an asset bundle.

This API is obsolete, BuildPipeline.BuildAssetBundles should be used instead. Creates a compressed unity3d file that contains a collection of assets. AssetBundles can contain any asset found in the project folder. This lets you stream resource data of any type, fully setup Prefabs, textures, meshes, animations, any type of asset shown in the project window. All paths are relative to the project folder, for example "Assets/MyTextures/hello.png".
Note that asset bundles built for standalone targets cannot be loaded by applications built for mobile platforms and vice versa. Furthermore, bundles are not compatible between iOS and Android platforms.

The function returns a boolean value which is true if the build succeeded and false otherwise.

See Also: BuildPipeline.BuildAssetBundles, AssetBundle, DownloadHandlerAssetBundle.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961