Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

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

BuildPipeline.BuildAssetBundle

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

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

Parámetros

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 WWW.LoadFromCacheOrDownload.

Descripción

Builds an asset bundle.

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. Like: "Assets / MyTextures / hello.png".


Note that asset bundles built for standalone or webplayer 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.


        
	// C# Example
	// Builds an asset bundle from the selected objects in the project view.
	// Once compiled go to "Menu" -> "Assets" and select one of the choices
	// to build the Asset Bundle
	
	using UnityEngine;
	using UnityEditor;

public class ExportAssetBundles { [MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")] static void ExportResource () { // Bring up save panel string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, 0); Selection.objects = selection; } } [MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")] static void ExportResourceNoTrack () { // Bring up save panel string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path); } } }

See Also: AssetBundle class, WWW.assetBundle.