x


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 ....

more ▼

asked Jun 06 '12 at 02:13 AM

firasdeep gravatar image

firasdeep
56 17 19 20

Me : 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

Me : My answer isn't relevant, moved into to comments so your back in the unanswered list.

Jun 06 '12 at 03:00 AM Berenger

If you're absolutely sure the file exists, I wonder if there might be a permissions issue. Maybe try some location other than the drive root.

Jun 06 '12 at 09:43 PM rutter
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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);
more ▼

answered Jun 06 '12 at 09:54 AM

mohanrao164 gravatar image

mohanrao164
146 3 3 5

Is that C# ? There should be a method in there.

Jun 06 '12 at 02:54 PM Berenger

thx for all who try to help me

Jun 06 '12 at 08:45 PM firasdeep

yes it is c# code the bottom 5 lines u can keep in ur required function

Jun 07 '12 at 04:44 AM mohanrao164
(comments are locked)
10|3000 characters needed characters left

use "file: //C:/Test.png",just add one whitespace after 'file:' it works on my pc

more ▼

answered Dec 18 '12 at 10:12 AM

kingzyt gravatar image

kingzyt
16

This is the only workaround, that fixed it on ALL of our Windows-PCs. (not tested on OSX)

Jan 29 at 10:58 AM JanWosnitza

Finally we figured out the real issue :D

According to File URIs in Windows file urls have to be formated like "file:///C:/ProgramFiles/...".

  1. "file://": protocol
  2. "/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( '\\', '/' ) );
Jan 30 at 09:37 AM JanWosnitza
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5092
x2209
x258
x238
x92

asked: Jun 06 '12 at 02:13 AM

Seen: 1067 times

Last Updated: Jan 30 at 09:43 AM