Can anyone tell me if there is a async version of LoadImage() method? I found about Resources.LoadAsync, however the method doesnt work.
Thank you
|
You're on the right track in the comments above when you ask whether the WWW class could help. This is how I've solved the problem in the past for asynchronously loading local image files as Texture2D data:
I don't know how much load-balancing Unity does on its own, but it might be good to avoid kicking off all 6GB of load requests at once. ;) Try pacing them out, so you only have a few requests running at a time, to avoid any major hitches. |
|||||||||
|
You can fire off a C# thread to load the image from a file, and get as far as turning it into a color array, with which you can quickly set a texture. So assuming you have some class
Now in the update method of your script, or some coroutine that runs every few milliseconds:
You have probably heard that Unity can't do threading, but it is only the case that most Unity objects will not function outside of the main thread. You can still fire off as many threads as you want and do whatever things you want in them, as long as you don't use those forbidden unity methods/objects. This may mean you have to roll your own image loading code, or find some open source code. It is possible the standard mono libraries will have what you need. You can see a similar example in my source where I am generating an image procedurally in the background here: https://github.com/jackmott/solescape/blob/master/Assets/src/MainMenu/MainMenuManager.cs |
||||
|