# LoadFromFileAsync

> Asynchronously loads an AssetBundle from a file on disk.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AssetBundleModule

## LoadFromFileAsync(string)

Asynchronously loads an AssetBundle from a file on disk.

```csharp
public static AssetBundleCreateRequest LoadFromFileAsync(string path)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Path of the file on disk.

### Returns

| Type                                                                                                | Description                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AssetBundleCreateRequest](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest.md) | Asynchronous load request for an AssetBundle. Use [AssetBundleCreateRequest.assetBundle](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest/assetbundle.md) property to get an AssetBundle once it is loaded. |

### Remarks

The function supports bundles of any compression type. In case of **LZMA** compression, the data will be decompressed to the memory. See AssetBundles compression for more details.

This is the fastest way to load an AssetBundle.

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

public class LoadFromFileAsyncExample : MonoBehaviour
{
    IEnumerator Start()
    {
        var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, "myassetBundle"));
        yield return bundleLoadRequest;

        var myLoadedAssetBundle = bundleLoadRequest.assetBundle;
        if (myLoadedAssetBundle == null)
        {
            Debug.Log("Failed to load AssetBundle!");
            yield break;
        }

        var assetLoadRequest = myLoadedAssetBundle.LoadAssetAsync<GameObject>("MyObject");
        yield return assetLoadRequest;

        GameObject prefab = assetLoadRequest.asset as GameObject;
        Instantiate(prefab);

        myLoadedAssetBundle.Unload(false);
    }
}
```

Additional Resources: [AssetBundleCreateRequest](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest.md), [AssetBundle.LoadFromFile](/engine/6000.6/script-reference/unityengine/assetbundle/loadfromfile.md).

## LoadFromFileAsync(string, uint)

Asynchronously loads an AssetBundle from a file on disk.

```csharp
public static AssetBundleCreateRequest LoadFromFileAsync(string path, uint crc)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Path of the file on disk.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): An optional CRC-32 checksum of the uncompressed content. If this is non-zero, then the content will be compared against the checksum before loading it, and give an error if it does not match.

### Returns

| Type                                                                                                | Description                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AssetBundleCreateRequest](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest.md) | Asynchronous load request for an AssetBundle. Use [AssetBundleCreateRequest.assetBundle](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest/assetbundle.md) property to get an AssetBundle once it is loaded. |

### Remarks

The function supports bundles of any compression type. In case of **LZMA** compression, the data will be decompressed to the memory. See AssetBundles compression for more details.

This is the fastest way to load an AssetBundle.

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

public class LoadFromFileAsyncExample : MonoBehaviour
{
    IEnumerator Start()
    {
        var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, "myassetBundle"));
        yield return bundleLoadRequest;

        var myLoadedAssetBundle = bundleLoadRequest.assetBundle;
        if (myLoadedAssetBundle == null)
        {
            Debug.Log("Failed to load AssetBundle!");
            yield break;
        }

        var assetLoadRequest = myLoadedAssetBundle.LoadAssetAsync<GameObject>("MyObject");
        yield return assetLoadRequest;

        GameObject prefab = assetLoadRequest.asset as GameObject;
        Instantiate(prefab);

        myLoadedAssetBundle.Unload(false);
    }
}
```

Additional Resources: [AssetBundleCreateRequest](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest.md), [AssetBundle.LoadFromFile](/engine/6000.6/script-reference/unityengine/assetbundle/loadfromfile.md).

## LoadFromFileAsync(string, uint, ulong)

Asynchronously loads an AssetBundle from a file on disk.

```csharp
public static AssetBundleCreateRequest LoadFromFileAsync(string path, uint crc, ulong offset)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Path of the file on disk.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): An optional CRC-32 checksum of the uncompressed content. If this is non-zero, then the content will be compared against the checksum before loading it, and give an error if it does not match.**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): An optional byte offset. This value specifies where to start reading the AssetBundle from.

### Returns

| Type                                                                                                | Description                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AssetBundleCreateRequest](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest.md) | Asynchronous load request for an AssetBundle. Use [AssetBundleCreateRequest.assetBundle](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest/assetbundle.md) property to get an AssetBundle once it is loaded. |

### Remarks

The function supports bundles of any compression type. In case of **LZMA** compression, the data will be decompressed to the memory. See AssetBundles compression for more details.

This is the fastest way to load an AssetBundle.

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

public class LoadFromFileAsyncExample : MonoBehaviour
{
    IEnumerator Start()
    {
        var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, "myassetBundle"));
        yield return bundleLoadRequest;

        var myLoadedAssetBundle = bundleLoadRequest.assetBundle;
        if (myLoadedAssetBundle == null)
        {
            Debug.Log("Failed to load AssetBundle!");
            yield break;
        }

        var assetLoadRequest = myLoadedAssetBundle.LoadAssetAsync<GameObject>("MyObject");
        yield return assetLoadRequest;

        GameObject prefab = assetLoadRequest.asset as GameObject;
        Instantiate(prefab);

        myLoadedAssetBundle.Unload(false);
    }
}
```

Additional Resources: [AssetBundleCreateRequest](/engine/6000.6/script-reference/unityengine/assetbundlecreaterequest.md), [AssetBundle.LoadFromFile](/engine/6000.6/script-reference/unityengine/assetbundle/loadfromfile.md).
