mainAsset | Permite especificar un objeto específico que se puede recuperar convenientemente utilizando AssetBundle.mainAsset. |
assets | Un arreglo de assets para escribir al bundle. |
pathName | El nombre del archivo donde se escribe el asset bundle comprimido. |
assetBundleOptions | Incluya automáticamente dependencias o incluya siempre assets completos en lugar de sólo los objetos referenciados exactos. |
targetPlatform | La plataforma para construir el bundle. |
crc | El parámetro opcional crc output se puede utilizar para obtener un checksum CRC para el AssetBundle generado, que se puede utilizar para verificar el contenido al descargar AssetBundles utilizando WWW.LoadFromCacheOrDownload. |
Construye un 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 targets cannot be loaded by
applications built for mobile platforms and vice versa. Furthermore, bundles are not
compatible between iOS and Android platforms.
La función retorna un valor boolean que es true si la construcción tiene éxito y false de lo contrario.
// 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); } } }
Mirar también: AssetBundle class, WWW.assetBundle.