- Home /
www problem (get image) ????
Hello
I have problem to get image from path at runtime.
var pic : Texture2D; function Start() { var pic2 : WWW = new WWW ("file://C:/Test.png"); yield pic2; pic = pic2.texture; }
and give me this error
You are trying to load data from a www stream which had the following error when downloading. Couldn't open file /Test.png
But when I change the root to //D it is work fine
var pic : Texture2D; function Start() { var pic2 : WWW = new WWW ("file://D:/Test.png"); yield pic2; pic = pic2.texture; }
thx for help ....
$$anonymous$$e : Test.png is in D:, not C:, simple as that.
firasdeep : no I have copy in C , E and D but not working in C and E only work in D root
thx for you try
I have Unity 3.4.1, is there are any bug in WWW in this version
$$anonymous$$e : $$anonymous$$y answer isn't relevant, moved into to comments so your back in the unanswered list.
If you're absolutely sure the file exists, I wonder if there might be a permissions issue. $$anonymous$$aybe try some location other than the drive root.
Answer by mohanrao164 · Jun 06, 2012 at 09:54 AM
Try this method i hope i will help full
public Texture2D tDynamicTx;
public WWW tLoad;
public string images;
images ="file://C:/Test.png";
tLoad= new WWW(images);
tDynamicTx= new Texture2D(64, 64);
tLoad.LoadImageIntoTexture(tDynamicTx);
GUI.Label(new Rect40,40, 64, 64), tDynamicTx);
yes it is c# code the bottom 5 lines u can keep in ur required function
Answer by kingzyt · Dec 18, 2012 at 10:12 AM
use "file: //C:/Test.png",just add one whitespace after 'file:' it works on my pc
This is the only workaround, that fixed it on ALL of our Windows-PCs. (not tested on OSX)
Finally we figured out the real issue :D
According to File URIs in Windows file urls have to be formated like "file:///C:/ProgramFiles/...".
"file://": protocol
"/C:/...": path
I believe Unity accepts the space version ("file: //C:/..") just because it has a very basic parsing implemented (e.g. if ( url.StartsWith( "file" ) ) url = url.Substring( 7 ) )
I recommend to build file urls like:
var url = "file:///" + Uri.EscapeUriString( path.Replace( '\\', '/' ) );
Thank you! In Windows 7, the double forward slash was enough to load it correctly, but for Windows Server 2008 R2 it seemed to fail...
When added a third forward slash ("file:///"+Application.strea$$anonymous$$gAssetsPath), it worked!
Your answer
Follow this Question
Related Questions
Best way to speed up loading texture from file 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Fetching files from disk at runtime 0 Answers
How do i acces files on mobile platforms? 0 Answers
compress photos on import 0 Answers