2
\$\begingroup\$

I have a bunch of Asset Bundles. I load the generic Asset Bundle Manifest to get the names of all of my asset bundles. I want to load only a specific asset from the bundle, but I need to retrieve the names of the assets so I can choose which one. The names of these assets are in the asset bundles manifests associated with each asset bundle.

How can I load just the manifest for a particular asset bundle?

This is the closest I have come, but it does not work:

private IEnumerator LoadAssetNames()
{
    foreach (var bundleName in assetBundleNames)
    {
        string url = "my://server/" + bundleName + ".manifest";
        var www = UnityWebRequest.GetAssetBundle(url);
        yield return www.Send();
        if (www.isError)
        {
            Debug.LogError(www.error);
            yield break;
        }
        var bundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle;
        www.Dispose();
        assetNames[bundleName] = bundle.GetAllAssetNames();
    }
}

It returns to me a failed to decompress error:

Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle 'my://server/bundleName.manifest'.

I can download the manifest directly as a string or set of bytes, but then how can I cast it to an AssetBundleManifest?

\$\endgroup\$
  • \$\begingroup\$ will it work if you replace the .manifest to .unity3d? \$\endgroup\$ – Justin Markwell Feb 24 '17 at 17:05
  • \$\begingroup\$ Anytime you want to type "but it does not work," please immediately follow that with a description of the precise way in which it does not work. Does it generate a compile error? A runtime error? Does it produce no result? The wrong result (in exactly what way is it wrong)? etc. The more clearly you describe the problem, the better the answers you're likely to get. \$\endgroup\$ – DMGregory Feb 24 '17 at 17:05
  • \$\begingroup\$ @DMGregory thanks for the reminder. I added the error I get. The reason I did not include it, is because the error is understood. I only included the code in the first place to show "What have you tried?". The real reason for this question is because there is no documentation anywhere. It is a relatively simple problem, but since it is new technology, the references on it are lacking. \$\endgroup\$ – Evorlor Feb 24 '17 at 17:20
  • \$\begingroup\$ Sorry to necro this. But did you ever figure out how to do this? Trying to do the same thing. \$\endgroup\$ – ribsies Apr 22 '18 at 1:16
0
\$\begingroup\$

Not sure if this is relevant or not any more but loading a manifest- according to Unity's docs requires loading the bundle and then grabbing the manifest.

string url = "my://server/" + bundleName

Instead of

string url = "my://server/" + bundleName + ".manifest"

Using AssetBundles

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.