# AssetBundle

> API for accessing the content of AssetBundle files.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AssetBundleModule
* **Inherits from:** [Object](/engine/6000.0/script-reference/unityengine/object.md)

```csharp
public class AssetBundle : Object
```

## Remarks

This class exposes an API, via static methods, for loading and managing AssetBundles.

This same class offers non-static methods and properties that expose the contents of a specific loaded AssetBundle, including the ability to load an Asset from within an AssetBundle.

Create AssetBundles by calling [BuildPipeline.BuildAssetBundles](/engine/6000.0/script-reference/unityeditor/buildpipeline/buildassetbundles.md) or using the [Addressables package](http://docs.unity3d.com/Packages/com.unity.addressables@latest/index.html). The build process generates one or more AssetBundle files, and each AssetBundle file contains a serialized instance of this class.

Note: AssetBundle.LoadAsset, and the other Load methods, do not support loading Scenes from AssetBundles.  Instead, in runtime you load the streamed scene AssetBundle and then call [SceneManager.LoadScene](/engine/6000.0/script-reference/unityengine/scenemanagement/scenemanager/loadscene.md) or [SceneManager.LoadSceneAsync](/engine/6000.0/script-reference/unityengine/scenemanagement/scenemanager/loadsceneasync.md) with the Scene name. In the Editor it is not supported to load Scenes from AssetBundles so calls to [EditorSceneManager.OpenScene](/engine/6000.0/script-reference/unityeditor/scenemanagement/editorscenemanager/openscene.md) will fail with an error that the Scene file is not found.

Additional Resources: [Intro to AssetBundles](/engine/6000.0/manual/assets-and-media/assets-managing-runtime/assetbundles-section/asset-bundles-intro.md), [UnityWebRequestAssetBundle.GetAssetBundle](/engine/6000.0/script-reference/unityengine/networking/unitywebrequestassetbundle/getassetbundle.md), [BuildPipeline.BuildAssetBundles](/engine/6000.0/script-reference/unityeditor/buildpipeline/buildassetbundles.md).

## Examples

```csharp
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class SampleBehaviour : MonoBehaviour
{
    IEnumerator Start()
    {
        var uwr = UnityWebRequestAssetBundle.GetAssetBundle("https://myserver/myBundle.unity3d");
        yield return uwr.SendWebRequest();

        // Get an asset from the bundle and instantiate it.
        AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
        var loadAsset = bundle.LoadAssetAsync<GameObject>("Assets/Players/MainPlayer.prefab");
        yield return loadAsset;

        Instantiate(loadAsset.asset);

        bundle.Unload(true);
    }
}
```

## Properties

| Property                                                                                                            | Description                                               |
| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [isStreamedSceneAssetBundle](/engine/6000.0/script-reference/unityengine/assetbundle/isstreamedsceneassetbundle.md) | Return true if the AssetBundle contains Unity Scene files |

## Static Properties

| Property                                                                                    | Description                                                                      |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [memoryBudgetKB](/engine/6000.0/script-reference/unityengine/assetbundle/memorybudgetkb.md) | Controls the size of the shared AssetBundle loading cache. Default value is 1MB. |

## Methods

| Method                                                                                                                | Description                                                     |
| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [Contains](/engine/6000.0/script-reference/unityengine/assetbundle/contains.md)                                       | Check if an AssetBundle contains a specific object.             |
| [GetAllAssetNames](/engine/6000.0/script-reference/unityengine/assetbundle/getallassetnames.md)                       | Return all Asset names in the AssetBundle.                      |
| [GetAllScenePaths](/engine/6000.0/script-reference/unityengine/assetbundle/getallscenepaths.md)                       | Return all the names of Scenes in the AssetBundle.              |
| [LoadAllAssets](/engine/6000.0/script-reference/unityengine/assetbundle/loadallassets.md)                             | Loads all Assets contained in the AssetBundle synchronously.    |
| [LoadAllAssetsAsync](/engine/6000.0/script-reference/unityengine/assetbundle/loadallassetsasync.md)                   | Loads all Assets contained in the AssetBundle asynchronously.   |
| [LoadAsset](/engine/6000.0/script-reference/unityengine/assetbundle/loadasset.md)                                     | Synchronously loads an Asset from the AssetBundle.              |
| [LoadAssetAsync](/engine/6000.0/script-reference/unityengine/assetbundle/loadassetasync.md)                           | Asynchronously loads an Asset from the bundle.                  |
| [LoadAssetWithSubAssets](/engine/6000.0/script-reference/unityengine/assetbundle/loadassetwithsubassets.md)           | Loads Asset and sub Assets from the AssetBundle synchronously.  |
| [LoadAssetWithSubAssetsAsync](/engine/6000.0/script-reference/unityengine/assetbundle/loadassetwithsubassetsasync.md) | Loads Asset and sub Assets from the AssetBundle asynchronously. |
| [Unload](/engine/6000.0/script-reference/unityengine/assetbundle/unload.md)                                           | Unloads an AssetBundle freeing its data.                        |
| [UnloadAsync](/engine/6000.0/script-reference/unityengine/assetbundle/unloadasync.md)                                 | Unloads assets in the bundle.                                   |

## Static Methods

| Method                                                                                                              | Description                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [GetAllLoadedAssetBundles](/engine/6000.0/script-reference/unityengine/assetbundle/getallloadedassetbundles.md)     | Get an enumeration of all the currently loaded AssetBundles.                                                                                                       |
| [LoadFromFile](/engine/6000.0/script-reference/unityengine/assetbundle/loadfromfile.md)                             | Synchronously loads an AssetBundle from a file on disk.                                                                                                            |
| [LoadFromFileAsync](/engine/6000.0/script-reference/unityengine/assetbundle/loadfromfileasync.md)                   | Asynchronously loads an AssetBundle from a file on disk.                                                                                                           |
| [LoadFromMemory](/engine/6000.0/script-reference/unityengine/assetbundle/loadfrommemory.md)                         | Synchronously load an AssetBundle from a memory region.                                                                                                            |
| [LoadFromMemoryAsync](/engine/6000.0/script-reference/unityengine/assetbundle/loadfrommemoryasync.md)               | Asynchronously load an AssetBundle from a memory region.                                                                                                           |
| [LoadFromStream](/engine/6000.0/script-reference/unityengine/assetbundle/loadfromstream.md)                         | Synchronously loads an AssetBundle from a managed Stream.                                                                                                          |
| [LoadFromStreamAsync](/engine/6000.0/script-reference/unityengine/assetbundle/loadfromstreamasync.md)               | Asynchronously loads an AssetBundle from a managed Stream.                                                                                                         |
| [RecompressAssetBundleAsync](/engine/6000.0/script-reference/unityengine/assetbundle/recompressassetbundleasync.md) | Asynchronously recompress a downloaded/stored AssetBundle from one [BuildCompression](/engine/6000.0/script-reference/unityengine/buildcompression.md) to another. |
| [UnloadAllAssetBundles](/engine/6000.0/script-reference/unityengine/assetbundle/unloadallassetbundles.md)           | Unloads all currently loaded AssetBundles.                                                                                                                         |

## Inheritance

**Inherited Members:**

* [Object.GetInstanceID()](/engine/6000.0/script-reference/unityengine/object/getinstanceid.md)
* [Object.GetHashCode()](/engine/6000.0/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.0/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.0/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectssortmode\))
* [Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive-findobjectssortmode\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.0/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindObjectsByType\<T>(FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectssortmode\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive-findobjectssortmode\))
* [Object.FindFirstObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindFirstObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindFirstObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindFirstObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type-findobjectsinactive\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.0/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.0/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.0/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.0/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.0/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.0/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
