How do I load an asset bundle from the manifest?

by Evorlor   Last Updated February 22, 2017 19:13 PM

I am trying to load a bunch of prefabs from an asset bundle. I am building the asset bundles for StandaloneWindows64:

BuildPipeline.BuildAssetBundles(BuildPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);

I load my asset bundle using Unity's new web request system:

var www = UnityWebRequest.GetAssetBundle(Url);
yield return www.Send();
if (www.isError)
    yield break;
var bundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle;

However, my bundle does not have my asset bundle in it. It only has the manifest:

//Output:  "1 asset: bundlemanifest"
Debug.Log(bundle.GetAllAssetNames().Length + " asset: " + bundle.GetAllAssetNames()[0]);

If I look at my manifest, I can see my asset bundle names "structures" does exist:

ManifestFileVersion: 0
CRC: 3317959940
      Name: structures
      Dependencies: {}

I tried retrieving it from my AssetBundleManifest:

var manifest = bundle.LoadAsset<AssetBundleManifest>("assetbundlemanifest");

But the AssetBundleManifest only has functions which return strings and Hash128s.

How can I instantiate the prefabs in my asset bundle named "structures"?

Related Questions

Unity asset bundle loading iOS

Updated August 21, 2017 13:13 PM

Unity C# reading .txt file on Mac OS

Updated November 08, 2017 20:13 PM

Load 3D model from external directory

Updated October 16, 2018 05:13 AM