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 UnrealSoftware · Jan 23, 2014 at 01:10 PM · texturewwwloadslowexternal

www-Class for loading local texture is very slow

Hey, I'm using the www-Class (http://docs.unity3d.com/Documentation/ScriptReference/WWW.html) to load textures from my local file system. I want people to be able to change these textures so I can't embed them in my project.

This worked fine a while ago but it now started to get REALLY slow for an unknown reason. Maybe one of the latest Unity3D updates caused this?! It now takes about 2-4 seconds for each www-Call which far too long when you consider that I'm just loading local files. The textures are png-files and they are really small as well (16x16 pixels).

The part taking so long is the www-Object itself to reach the status www.isDone==true. Actually accessing the texture afterwards is fast.

Does anyone have the same problem or know why this happens or how to solve it?

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

2 Replies

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

Answer by greg-harding · May 26, 2015 at 02:27 PM

We just hit this problem as well with Unity 5.0.2 / Windows 7 x64 using WWW to load local image files using;

 var www = new WWW("file:///path/to/file");

Depending on the state of the network connection the local image load is either instant or Unity blocks and the image load takes 3-4secs. The test images are ~50k jpg's so they should load nearly instantly every time. The same applies for loading other content types, not just images.

We haven't fully tracked it down yet but using ProcessMonitor we can see that even loading a local file (using WWW with file:///) Unity appears to ask the OS/network stack some things (it loads dlls and does some other weirdness) but doesn't make an actual outgoing network connection, and then it loads the local file.

We noticed that if there is a gateway in the network settings but no internet connection Unity blocks for 3-4secs and then loads the local image ok. After unplugging the network, disabling the network stack, or updating the gateway (ie. a usual connected state or no connection) Unity loads the image immediately. It's a strange bug and sometimes seems dependent on whether a full connection or non-connection exists at the first request or not. Plugging/unplugging the network connection while the app is running also makes the images load immediately or with the blocking problem - nothing appears cached from Unity talking to the OS/network stack when making further WWW requests for local files.

The workaround is easy enough for our case - we simply load the local image via a byte array and load it into a texture;

 try {
   byte[] binaryImageData = File.ReadAllBytes(localImagePath);
   contentTexture.LoadImage(binaryImageData);
 }
 catch {...}
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 UnrealSoftware · May 26, 2015 at 04:36 PM 0
Share

Good workaround for textures! Thank you very much for sharing!

Edit: The problem with this is that you need to know the image size for that. You can use this http://stackoverflow.com/a/112711/1610618 code to get it.

avatar image
0

Answer by UnrealSoftware · Jan 28, 2014 at 01:32 PM

I found it out myself. Unity3D fails to choose the correct network adapter automatically I guess. I have Hamachi installed on my system and it looks like Unity3D first tries to use the network adapter of Hamachi with EVERY new www-request you make. This also affects the Unity3D asset store which is incredibly slow because of this problem.

The solution I found is very simple (but a bit inconvenient for Hamachi users): Disable the network adapter of Hamachi while using Unity3D.

I assume that the same problem can also be caused by other installed network adapters and not only by Hamachi network adapters.

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

19 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

Related Questions

Load external mp3 File without streaming 1 Answer

Loading textures into an array after build 1 Answer

Webplayer crash on LoadImageIntoTexture call 1 Answer

How can I load texture files that are outside of my project folders? 1 Answer

the texture appear rubbish 1 Answer


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