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
0
Question by Tipoun · Apr 13, 2012 at 12:23 PM · c#www

Load local file with WWW

Hello,

I try to load a local file with WWW class. Everything works fine, however isDone function return too early. Width the following code:

     var path = paths[0];
     WWW w = new WWW("file://" + path);
     Debug.Log("1: " + Time.realtimeSinceStartup);
     while (!w.isDone)
     {
         Debug.Log("not done");
     }
     Debug.Log("2: " + Time.realtimeSinceStartup);
     images.Add(w.texture);
     Debug.Log("3: " + Time.realtimeSinceStartup);

I've got:

     1: 0.02761436
     2: 0.03673011
     3: 0.3329855

There's something wrong here no ?

Regards

EDIT : I tryed with a distant file, and everything works correctly.

Comment
Add comment · Show 4
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 rutter · Apr 14, 2012 at 03:26 AM 1
Share

Local file access is generally pretty quick. Are you actually encountering a problem, or just expecting one? I'm a little confused. :|

avatar image GuyTidhar · Apr 14, 2012 at 08:32 AM 0
Share
  1. Debug.Log calls are expensive on performance.

  2. Generally speaking - Don't do while (!w.isDone) {} calls without yield or yield with WaitForSeconds(). This is very bad program$$anonymous$$g since it freezes the application/game until a process is done, something you should never do (the term is called "Busy Waiting") - you should always enable your program to continue its main process without doing freezes.

avatar image Tipoun · Apr 16, 2012 at 08:33 AM 0
Share

Thank's for your answers.

@rutter: I'm encountering a problem. I am thinking that the loading proceed during the call to .texture for "file:///" protocol.

@guyt: Ok for Debug.Log, it is to illustrate my example. In my real application, I use "yield". I just created a small program to show you.

avatar image Tipoun · Apr 24, 2012 at 11:17 AM 0
Share

Finally, I have found the problem : there is a delay during the loading of the texture into my Texture2D variable. I try to use LoadImageIntoTexture, but I have the same problem.

I think it is during parsing of received bytes. I can't reduce image size, but I would like to know if there is a way to thread this parsing.

Regards

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GuyTidhar · Apr 14, 2012 at 08:34 AM

I'd try removing the Debug.Log("not done"); within the while loop and then test for times.

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

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

6 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

A node in a childnode? 1 Answer

Screenshot multiple 1 Answer

C# how to save values to a File and Load Values from a File 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