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
2
Question by Paulo-Henrique025 · Aug 17, 2013 at 01:40 PM · textureyieldwww class

How to use WWW to load Local files?

Hi guys, when I first thought of doing this, I thought there would be no problem but now I'm stuck for hours in this.

What kind of path should I provide to the WWW constructor?

It has to have "file://" as protocol?

Do I need to yield?

here is my current, not working, implementation:

 public class loadwww : MonoBehaviour {
 
     public Texture2D tex;
     public WWW w;
 
     void Start()
     {
         LoadTex();
     }
 
     void LoadTex ()
     {
         w = new WWW ("file://Users/Paulo/Desktop/img_2013_008_original.jpg");
     }
 
     void Update () 
     {
         if(w.isDone)
         {
             Debug.Log("done");
             tex = w.texture;
         }
     }
 }

And the error it's presenting:

You are trying to load data from a www stream which had the following error when downloading. Couldn't open file /Paulo/Desktop/img_2013_008_original.jpg UnityEngine.WWW:get_texture() loadwww:Update() (at Assets/MakeLy/Scripts/loadwww.cs:24)

ANSWER:

The root in OSX is /Users, so the correct URL is file:///Users/[...] with three / instead of only two.

Comment
Add comment
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

4 Replies

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

Answer by Paulo-Henrique025 · Aug 17, 2013 at 03:52 PM

The root in OSX is /Users, so the correct URL is file:///Users/[...] with three / instead of only two.

Comment
Add comment · 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
3

Answer by ArkaneX · Aug 17, 2013 at 01:58 PM

You lack drive info in your URL. It probably has to be "file:///c://Users/......". And regarding 'yield' - yes - you should use WWW loading inside coroutine, like in this example.

Comment
Add comment · Show 2 · 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 Paulo-Henrique025 · Aug 17, 2013 at 03:49 PM 0
Share

Thank you for your answer, I'm using OSX and turns out the root folder is /Users, so the correct path is file:///Users/[...] with that third /. Thank you for effort anyway :)

avatar image ArkaneX · Aug 17, 2013 at 04:03 PM 0
Share

I hope this will $$anonymous$$ch me not to assume that someone uses Windows :)

avatar image
2

Answer by Joyrider · Aug 17, 2013 at 01:58 PM

You need to add your drive to the path: "file://c://Users/..."

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 Paulo-Henrique025 · Aug 17, 2013 at 03:50 PM 0
Share

Thank you for your answer, I'm using OSX and turns out the root folder is /Users, so the correct path is file:///Users/[...] with that third / .Thank you for effort anyway :)

avatar image abi-kr01 · Jun 17, 2014 at 10:43 AM 0
Share

Thank you it worked for me

avatar image devean · Jan 21, 2015 at 05:10 AM 0
Share

can you plz tell how did it worked???

avatar image
2

Answer by EMR_1 · Aug 16, 2018 at 11:13 PM

I am loading an image stored to the local drive. The Application.persistentDataPath string to the file does not include the prepended "file://". Instead of just manually adjusting the string I am using UriBuilder to achieve the same result, perhaps with more portability:

String tFullPathName = Application.persistentDataPath + "/" + folderName + "/" + filename;
UriBuilder tURIBuilder = new UriBuilder( tFullPathName );
tURIBuilder.Scheme = "file"; // Uri.UriSchemeFile is not available when building for UWP (?). It is the string "file" so I just use the string here. 
WWW tWWW = new WWW( tURIBuilder.ToString() );

Comment
Add comment · Show 1 · 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 Wijari · Jul 23, 2019 at 05:11 PM 0
Share

thanks, this works for me

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

20 People are following this question.

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

Related Questions

Crossdomain.xml Google Drive 0 Answers

www class blocks script execution 1 Answer

Download image files from server with WWW and store it in local storage 3 Answers

using www to fill scrollarea 0 Answers

WWW yield is not returning any value in ios for yahoo finance api 2 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