Yes, it’s another odd one I’ve been trying to find a way to write a downloaded asset bundle to disk for later use. Using the following code, however, results in 1 byte files which obviously means something is going haywire:
string url;
int count = 0;
foreach(string entry in buildFiles)
{
Debug.Log(entry + "Downloading...");
url = host + "resources/" + entry;
www = new WWW(url);
yield return www;
Debug.Log(entry + "Done!");
Debug.Log(count);
Debug.Log(www.assetBundle.mainAsset);
assetBundles[count] = www.assetBundle;
FileStream fs = new FileStream(folderPath + "/" + entry, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(www.assetBundle);
bw.Close();
fs.Close();
count++;
}
What would be the proper way to write an assetBundle downloaded through a WWW object to disk so it can be loaded from disk later?