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; } 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 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"?
BuildPipeline.BuildAssetBundlesand whereUrlpoints (in your web request).BuildPipeline.BuildAssetBundlesreturns a manifest and thenBuildPathis 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. \$\endgroup\$Application.streamingAssetsPath, you don't need to deal withWWW, you can directly callAssetBundle.LoadFromFile. (WWWcreates excessive amounts of garbage so only use it if you must) \$\endgroup\$structures.manifestand one namedstructures_XXXXXXXXwhere the X's are a hash. You want to make sure you're downloading the one with the underscore, hash, and no file extension. \$\endgroup\$