• 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 cncguy · May 13, 2012 at 07:17 AM · texturewwwloadimageintotexture

Glitch when using WWW.LoadImageIntoTexture(...)

The Function WWW.LoadImageIntoTexture(Texure2D tex) causes a glitch in the application due to Texture.AwakeOnLoad() which can be seen in the profiler.

I have seen other people ask about this in the forums and also here on unity asnwers as well. I haven't seen any real solutions though. The ideal would be to do the LoadImageIntoTexture bit in another thread - however this is not possible because you can't use the Unity API in a separate thread.

My application requires loading a number of jpgs at run time - it is based on the context of where you are in the application and they can't be loaded ahead of time. Ie. they need to be able to be loaded at run time without causing a noticeable stall in the application.

I have currently been exploring how to implement my own AsyncOperation but it is not apparent if this is possible/will work from looking at the documentation and probing with System.Reflection. All I have seen is a comment that this is 'not a good idea' which just makes me want to do it all the more:)

I have seen a few mentions of using LoadLevelAdditiveAsync -> I think this would be a messy way to have to do it as I want to be able to load raw jpgs, ie. not have to do some postprocessing on them to give me something to load as a level (I have a lot of textures to load...).

The last thing I am thinking of is to save all the textures as saperate asset bundles however a texture saved as an asset bundle I'm pretty sure still calls Texture.Awakefromload when called out of the assetbundle.

So after all the Bla Bla Bla above the question is how can I load a texture at runtime without incurring a stall when it calls Texture.AwakeFromLoad()?

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
1

Answer by bompi88 · May 13, 2012 at 08:04 AM

Try the thread idea. Found something interesting here. Take a look at it. I haven't tried it, but looks awesome.

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 cncguy · May 13, 2012 at 08:03 PM 0
Share

Hi that looks pretty useful - thanks. It doesn't solve the issue above because unity API calls can only happen in the main thread which would still cause a glitch. However I still can find lots of uses for what you have just pointed out so thanks again.

avatar image bompi88 · May 13, 2012 at 09:24 PM 0
Share

Ok, I thought you would do something like:


UnityThreadHelper.Dispatcher.Dispatch(() => Instantiate(Resources.Load(objectToInstantiate)));

I have poor knowledge about threading :S I have to get into it later on. O$$anonymous$$, I understand it now ;-) It will still happen in the main thread :S

avatar image Roman500 bompi88 · Aug 15, 2016 at 07:55 PM 0
Share

Can you please tell why it still will happen in the main thread? It has method "UnityThreadHelper.CreateThread(DoThreadWork)" which will, I suppose, create a new thread? Am I wrong?

avatar image
0

Answer by stijn · May 13, 2012 at 10:16 PM

The problem is it takes a long time (on the main thread) to load the image into video memory.

A second problem is that resizing the image is only possible after loading it into video memory (which is too late)

I'm dealing with this same problem, I wrote a working solution using FJCore, which is too slow so I made a feature request. Check out my question here:

http://answers.unity3d.com/questions/249993/typeloadexception-trying-to-use-fjcore-fluxjpeg.html

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

LoadImageIntoTexture on iPhone from the device disk 1 Answer

Webplayer crash on LoadImageIntoTexture call 1 Answer

Is there a way to replace the question mark in the WWW.LoadImageIntoTexture? 2 Answers

Image loaded with LoadImageIntoTexture gets inverted 0 Answers

Loading Images using WWW into a different texture format 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