I am trying to load an image file from streamingassets. I figured a potential workaround was to write the image file to the persistentdatapath as that seemed to help others. I have checked every forum post and attempted to implement the solution, to no success. I am looking for any solution, and I hope this isnt a duplicate. I have tried for days to get this to work, unsuccessfully. I can verify on my computer filesystem that I am able to write the file to the persistentdatapath. My only theory is that maybe my usb debugging settings are not allowing access or something. Here’s my code, I hope someone can help.
void Start () {
WWW reader = new WWW(Application.streamingAssetsPath+"/bundle.jpg");
while (!reader.isDone) { }
string realPath = Application.persistentDataPath + "/bundle.jpg";
System.IO.File.WriteAllBytes(realPath, reader.bytes);
dbPath = realPath;
WWW www = new WWW(dbPath);
while (!www.isDone) { }
Texture2D tex = www.texture;
GameObject.Find("FilePath").GetComponent<Text>().text = Application.streamingAssetsPath;
GameObject.Find("Picture").GetComponent<Image>().sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(.5f, .5f));
}
Thanks in advance.