- Home /
Question by
tqkiettk10 · Dec 29, 2015 at 05:21 AM ·
assetbundlewwwbytes
cannot get bytes in WWW
Hi everyone. I try to store assetbundle but it donot work
WWW download;
string url ="file://"+ Application.dataPath + "/assetBundle/images";
Debug.Log(url);
download = WWW.LoadFromCacheOrDownload(url, 0);
yield return download;
AssetBundle assetBundle = download.assetBundle;
if (assetBundle != null)
{
// Alternatively you can also load an asset by name (assetBundle.Load("my asset name"))
GameObject go = assetBundle.LoadAsset<GameObject>("myasset");
if (go != null)
Instantiate(go);
else
Debug.Log("Couldn't load resource");
}
if (string.IsNullOrEmpty(download.error))
{
string cachedAssetBundle = Application.dataPath + "/savedassetbundle.assetbundle";
System.IO.FileStream cache = new System.IO.FileStream(cachedAssetBundle, System.IO.FileMode.Create);
byte[] bytes = download.bytes;
cache.Write(bytes, 0, download.bytes.Length);
cache.Close();
}
here is error: WWWCached data can only be accessed using the assetBundle property! UnityEngine.WWW:get_bytes()
I can Instantiate my image but i can't get download.bytes?
Comment