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()?

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

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: