name | Corresponding resource name in assetbundle. |
AssetBundleRequest Asynchronous load request from an AssetBundle.
Allow the user to implement asynchronous instantiation.
using UnityEngine; using System.Collections; using System.IO;
public class Example : MonoBehaviour { AssetBundle myLoadedAssetBundle;
void Start() { //load Assetbundle myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "myassetBundle")); if (myLoadedAssetBundle == null) { Debug.Log("Failed to load AssetBundle!"); return; } // Use a coroutine to Instantiate in the background StartCoroutine(InstantiateAsyc()); } IEnumerator InstantiateAsyc() { yield return myLoadedAssetBundle.InstantiateAsync(myLoadedAssetBundle.GetAllAssetNames()[0]); }
}