Store and load any files from AssetBundles

how this came about is that I was trying to store a .SWF file in an asset bundle and then load it at runtime, so that I could send it’s location to a stand alone flash player. This way it would load locally and not in a browser, so I would have full control over compatibility.

Unity limits the type of files that can be put into assetbundles so you need to change the extension on the file to “.bytes” and then it will be packed into the assetbundle as is.

You then load that file out of the assetbundle as a byte array and write it to a temporary file in your Assets folder at runtime, changing the extension on the file to be whatever is needed, in this case “.SWF”.

You now have a file taken out of the assetbundle and in a location where you can do anything with it. This allows you to store any file type inside an assetbundle and retrieve it for use in any way you like!

This process in BOLT

Leave a Reply