- Home /
Cant get streaming assets folder to work with the www class
Hello Unity peeps,
So i keep getting the following error with my code:
You are trying to load data from a www stream which had the following error when downloading. malformed
And heres my code:
string url = Application.streamingAssetsPath + "/" + textureName;
WWW www = new WWW(url);
yield return www;
gameObject.renderer.material.mainTexture = www.texture; //error points to this line
It works fine if i use a http address for the url which makes me think i might using it wrong but from reading the docs i thought this was okay?!?! Anywho any help would be great, im using unity 3.5.7, on a mac building for iOS and Android.
Answer by DaveA · Aug 28, 2013 at 05:10 PM
string url = "file://"+Application.streamingAssetsPath + "/" + textureName;
Try that
thanking you Sir, i made 2 school boy errors, one being the missing "file://" at the beginning and the other missing the file type at the end
string url = "file://"+Application.strea$$anonymous$$gAssetsPath + "/" + textureName + ".jpg";
You should never manually combine path for Strea$$anonymous$$gAssetsPath. Use System.IO.Path.Combine(Application.strea$$anonymous$$gAssetsPath, "file to load"); ins$$anonymous$$d :)
If anyone is curious as to why, read this: https://startbigthinksmall.wordpress.com/2008/05/28/pathcombine-does-more-then-just-putting-a-between-to-strings-use-it/
Android platform is exception from this rule. Android strea$$anonymous$$g assets path already has "file:" in it. #if UNITY_EDITOR || !UNITY_ANDROID url = "file://" + url; #endif