Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by firasdeep · Jun 06, 2012 at 02:13 AM · textureimagepathfiles

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Berenger · Jun 06, 2012 at 03:00 AM 0
Share

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

avatar image rutter · Jun 06, 2012 at 09:43 PM 0
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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);
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Berenger · Jun 06, 2012 at 02:54 PM 0
Share

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

avatar image firasdeep · Jun 06, 2012 at 08:45 PM 0
Share

thx for all who try to help me

avatar image mohanrao164 · Jun 07, 2012 at 04:44 AM 0
Share

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

avatar image
3

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JanWosnitza · Jan 29, 2013 at 10:58 AM 0
Share

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

avatar image JanWosnitza · Jan 30, 2013 at 09:37 AM 1
Share

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( '\\', '/' ) );

avatar image jlupianez_freedom · May 06, 2015 at 08:58 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges