Version: 1.5
LanguageEnglish
  • C#

AssetBundle.PreDownloadAsAssetAsync

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

Declaration

public PreDownloadAsAssetRequest PreDownloadAsAssetAsync(Object obj);

Description

Asynchronously predownloads autostreaming assets in obj from the bundle and checks if loaded .


Declaration

public PreDownloadAsAssetRequest PreDownloadAsAssetAsync(Object obj);

Description

Asynchronously predownloads autostreaming assets in obj of a given T from the bundle and checks if loaded .

using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;

public class LoadBundleTest : MonoBehaviour { private void Start() { StartCoroutine(LoadTest()); }

IEnumerator LoadTest() { UnityWebRequest unityWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(Path.Combine(Application.streamingAssetsPath, "AssetBundles/bundle")); yield return unityWebRequest.SendWebRequest(); AssetBundle ab = (unityWebRequest.downloadHandler as DownloadHandlerAssetBundle).assetBundle; if (ab != null) { AssetBundleRequest assetBundleRequest = ab.LoadAssetAsync<GameObject>("prefab"); yield return assetBundleRequest;

var preRequest = ab.PreDownloadAsAssetAsync<GameObject>(assetBundleRequest.allAssets[0]); yield return preRequest; Instantiate(assetBundleRequest.allAssets[0] as GameObject); } } }

Declaration

public PreDownloadAsAssetRequest PreDownloadAsAssetAsync(Object obj, Type type);

Description

Asynchronously predownloads autostreaming assets in obj of a given type from the bundle and checks if loaded .