asset bundle on android

Hello,

I am having a little issue with loading an asset bundle from the sdcard of an android device. What I hope to accomplish is to download an asset bundle, save it on the SDcard on an android device, then load it from the SDcard. I can save the .unty3d file to the sdcard with no issues, but the issue is loading it in to the game. Seeing as there is no way to load an asset bundle without the www class, I use the www class with the file:// protocol like so:

WWW www = new WWW (@"file:///sdcard/items/shirt.unity3d");

I also tried using this

WWW www = WWW.LoadFromCacheOrDownload  (@"file:///sdcard/items/shirt.unity3d",1);

but I get the same results.

what happens is that www.error is null (so, no errors), but, so is www.assetBundle! (this should not be null). So naturally, the following line does not work:

GameObject go = (GameObject)Instantiate(www.assetBundle.mainAsset);

The tricky part is that the exact same code works well while using/testing it in the editor. The only difference is that I change the file path to some remote dir on my computer. Also, while on the phone, I can read the unity3d file I want with a BinaryReader. I have some test code in the same co-routine to verify that the file exist, and can be read from.

any ideas on what is going on?

thanks,

seems to be a bug or something. I used the example code from the docs, and I got the same result. So, running the C# code from here:

will not create the object that was downloaded. (obviously, i had to use my own .unity3d file and my own server)

So, i made a bug report and I hope to hear something back soon.

Thanks again unity forums for your wisdom and speedy replies!

isn’t the sd card under /mnt/sdcard/… ?
doesn’t look like a *nix path at all if it tries to access a device without /mnt jump first (or /media if it were a modern desktop *nix)

I didnt need /mnt/ int he path. I verified this by creating a text file in the directory I wanted, as well as opened the actual assetBundle with a BinaryReader.

Figured it out. I had to specify the asset bundle build target. so its different for all platforms.Once I made it specific for android, it worked. Woulda been nice if the docs ( Unity - Scripting API: BuildPipeline.BuildAssetBundle ) woulda told me this is NEEDED and not an optional param!!!

1 Like

The doc there needs update, prior 3.2 or 3.3 it was not possible to build any for mobile and now its not fully up to date anymore.
you best report a bug (the bug reporter has a doc category)