# How do I load an asset bundle?

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)
{
Debug.LogError(www.error);
yield break;
}


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
AssetBundleManifest:
AssetBundleInfos:
Info_0:
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"?

• Can you clarify what you're doing with the results of BuildPipeline.BuildAssetBundles and where Url points (in your web request). BuildPipeline.BuildAssetBundles returns a manifest and then BuildPath is where the bundles are created. Note that each bundle also has a corresponding .manifest file that can be ignored in most cases; the actual bundle wont have an extension and that's the file you want to load. Feb 22, 2017 at 20:26
• I also noticed you tagged the question with "streaming-assets". If you're putting the bundles in Application.streamingAssetsPath, you don't need to deal with WWW, you can directly call AssetBundle.LoadFromFile. (WWW creates excessive amounts of garbage so only use it if you must) Feb 22, 2017 at 20:29
• @GuntherFox I am taking the asset bundles/manifests/etc and putting them on a local server. I am then using the URL of that local server.
– Evorlor
Feb 22, 2017 at 20:40
• Does your URL include the underscore and the hash for the actual bundle file? When you build a bundle named "structures" it will create two files: one named structures.manifest and one named structures_XXXXXXXX where the X's are a hash. You want to make sure you're downloading the one with the underscore, hash, and no file extension. Feb 22, 2017 at 21:09
• @GuntherFox OK. I have no idea. This is where I am stuck? I cannot find access to my structures. The only reference I can find to it is the string name of it, which is not helpful.
– Evorlor
Feb 22, 2017 at 21:18