Understanding AssetBundles (WWW) BuildPipeline

I’m trying to get my head around Unity’s AssetBundle class, which allows me to export assets, and then download and import them over the web.

The issue I’m having is that my Unity project is for iOS, so every time I run the ‘BuildAssetBundle’ example found here:

It changes my build platform from iOS, to Web Player and then exports out successfully. When I change my build platform back to iOS and play within the editor, it successfully downloads the asset bundle from my FTP (WWW), but when I try it on my iPhone, it crashes. Here is the log:

The file can not be loaded because it
was created for another build target
that is not compatible with this
platform. Please make sure to build
asset bundles using the build target
platform that it is used by. File’s
Build target is: 6

Do you think it has something to do with the fact its changing the build platform from iOS to Webplayer? And then me having to change it back?


----- UPDATE -----

I found that if I put ‘BuildTarget.iPhone’ within the ‘ExportAssetBundle’ example script - it keeps my built platform to iOS. Still works within the Editor, but same error on my iPhone, same log. (And yes, I have uploaded the new bundle to my FTP).

Here is a very useful editor script that I got from Sergey Taraban … I did not find the link to the actual file so uploading one for you.

Please find it here: AssetBundleExporter

This allows you to choose your platform for creating asset bundle and also you can manage the split size of your asset bundle… this proved very helpful to me.

Hope it does the same for you.