Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by ElChileVengador · Nov 18, 2015 at 02:25 AM · streamingassetsloading fileloading during runtime

Can't open file when loading from WWW stream

Hi everybody,

I'm new to loading files and I'm trying this simple code to load an image into a quad as a texture. Hoever I keep getting the following error:

You are trying to load data from a www stream which had the following error when downloading. Couldn't open file C:\presentacion001.jpg

My image (named "presentacion001") is located in the root C folder. This is my code:

     public IEnumerator LoadPresentation_Images() {
         //different parts of the file name
         string pathPrefix = @"file://";
         string pathImageAssets = @"C:\";
         string filename = @"presentacion001";
         string fileSuffix = @".jgp";
 
         string fullFileName = pathPrefix + pathImageAssets + filename + fileSuffix;
 
         WWW webAccess = new WWW(fullFileName);
         yield return webAccess;
         Texture2D texTemp = new Texture2D(64, 64, TextureFormat.DXT1, false);
         webAccess.LoadImageIntoTexture(texTemp);
         presentationRenderer.material.mainTexture = texTemp;
 
     }

I'm pretty sure my error is quite basic, but I can't seem to figure it out. Could anyone help me pinpoint it out?

Thanks!

Comment
Add comment · Show 1
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 saschandroid · Nov 18, 2015 at 07:40 AM 1
Share

Try this: "When using file protocol on Windows and Windows Store Apps for accessing local files, you have to specify file:/// (with three slashes)." (WWW)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Nov 18, 2015 at 07:52 AM

Typo in line 6?

 "jgp" should be "jpg"

Besides that like saschandroid mentioned in the comments the file scheme needs 3 slashes and not 2

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
0

Answer by ElChileVengador · Nov 18, 2015 at 11:38 PM

Thanks @saschandroid and @Bunny83 I've tried what you recommended and also changed all the slashes to '\' as that was another typo (I've actually tried both slashes), but I still get the same error message.

Also tried changing ".jpg" to ".jpeg", but to no avail.

Anything else that I could be doing wrong?

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 ElChileVengador · Nov 19, 2015 at 12:26 AM 0
Share

Just for FYI I tried using File.Exists and it can find the file. I've swicthed to reading all bytes and using LoadImage to get the functionality.

http://docs.unity3d.com/ScriptReference/Texture2D.LoadImage.html

However, just as a learning experience, I'd really appreciate if anyone can point me to what is wrong with my previous approach...

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

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

Resources not loading from Application.PersistentDataPath in Editor 1 Answer

How do I load an audio file from persistantdatapath? 0 Answers

How can I load an m4a file into an AudioClip? 1 Answer

How to load NavMesh from streaming assets at runtime 0 Answers

read write xml file on ipad ,Access denied 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