- Home /
Question by
Posthuman-Wizard · Jul 23, 2013 at 05:53 PM ·
texture2dimagewwwruntimestreamingassets
How to load an image at runtime via WWW correctly
Hello everyone,
I have an image in my Streaming Assets folder that I want to load at run-time and use as a texture. However, when I attempt to do this, I get an error that reads:
You are trying to load data from a www stream which had the following error when downloading. Could not resolve host: C; No data record of requested type
Here is the code that is throwing the error. Any help would be greatly appreciated.
Texture2D imageTexture;
var path = System.IO.Path.Combine(Application.streamingAssetsPath,"image.png"); Debug.LogError(path);
WWW www = new WWW (path);
yield return www;
imageTexture = www.texture;
Comment
Answer by pitimoi · Jul 23, 2013 at 06:11 PM
Hi Josh,
I you want to use Application.streamingAssetsPath in a WWW stream, you should add "file:///" before it.
The WWW class is trying to reach an url, and "file:///" is pointing to your computer files.
var path = System.IO.Path.Combine("file:///"+Application.streamingAssetsPath,"image.png");
Have fun ;)