- Home /
Question by
Ony · Jun 14, 2010 at 06:25 AM ·
assetbundledownloadlocal
How to download an asset bundle to local hard drive?
How can I download an asset bundle (in a standalone app, not web player) and save it to a folder on the local hard drive?
I know how to download one and then instantiate it, but I'm not clear on the saving to hard drive part.
Comment
Answer by Ony · Jun 14, 2010 at 06:49 AM
Ok I got it figured out so I'll put it here for anyone else looking. If anyone has a better way to do it please post here:
import System.IO; var path = "local path on hard drive to write to";
function SaveDownloaded(filename) {
Debug.Log("Attempting to download this file: "+filename);
var fileURL = "www.yourdomain.com/assets/"+filename;
var www : WWW = new WWW (fileURL);
yield www;
var bytes = www.bytes;
File.WriteAllBytes(path+"/" + filename, bytes);
}
what is the 'filename' in your case? and how to export assetbundle correctly?