- Home /
Hiccups when loading images from resources folder
Hi! At some point in my game, I need to display some simple 2D animations which are made from several sprites (some of them quite big) that I translate/rotate/scale around the scene following a script. All the sprites are located in the resources folder.
At the moment, I'm preloading the first few sprites I need and then I load the rest in a co-routine that executes along with the animation playback so that the rest of the sprites can be ready when needed. Although this method works, the main problem I'm facing is that the application suffers a hiccup when the co-routine calls Resources.Load, which can be quite noticeable.
I've been searching around unity answers and, to the best of my understanding, there's no way to invoke Resources.Load as an asynchronous function. In fact, there seems to be a request for such a feature.
I've also tried the approach suggested in this thead but, just like the original poster, I'm also experiencing hiccups when loading big images.
I've changed my coroutine approach and replaced it with threads using this handy library but, again, the hiccups are still there.
Can you suggest any way to get rid of the hiccups? Thanks in advance for your help!
Cheers,
--Nacho
Answer by Fattie · Apr 08, 2013 at 05:24 AM
Note .. for 2016 Unity have recently added LoadResourceAsync
which can be relevant.
Tragically there is no solution to this in the current version of Unity.
We have investigated this every way and the fact is Unity is not good at streaming in big images. (It's fine at getting big sounds from disk!)
Here's one of many questions about it ...
http://answers.unity3d.com/questions/393460/resourcesload-async-for-large-images.html
(Note for example the "WWW" class approach ..... you can and should try that but .. it also hiccups.)
You can't load large images on the fly in Unity -- it is how life is for now.
Thank you for your reply. It's really unfortunate that there's no way to stream image data asynchronously! Oh well, I guess we'll have to work around that. Thanks again for your input!
The big problem is probably the upload to the GPU right? That and all the screwing around with writability etc.
dude I'm totally unsure if it relates to loading to the GPU...I fear not
I've found, with Unity it's simply not possible to "load smoothly" (stream, if you will) a large file.
TBC Unity does this flawlessly, brilliantly, with large AUDIO files, but it does not work with other types of files.
For example, you can just try loading-smoothly a massive text file, it won't work.
Regarding writability, that is not the issue, me and the bloke from 2DToolkit screwed around massively with that and that was not the woe.
In my useless opinion,
http://docs.unity3d.com/Documentation/ScriptReference/AsyncOperation-allowSceneActivation.html
that was the "biggest thing missing" from Unity ("WTF, a game engine where you can't keep an animation going while it loads the next level in the BG ?!"
incredibly they fixed that which was just totally awesome and amazing of Unity and I love them.
I$$anonymous$$UO, the biggest thing CURRENTLY missing from this issue is just that - it's nuts that you can't stream in a file without hiccups (other than audio, which works perfectly)
the classic example is you want to bring up a full-screen card between levels of your game
INDEED -- a somewhat related problem in Unity. It's very badly handled / can't be done to simply unload an asset.
it's nuts that you can't: have a couple of textures for your spaceships, and then unload those when you've left that part of gameplay and load the textures fo rthe neutronbikes.
a great example is cganing backgrounds on a 2.5D, it's nuts you cant firmly-get-rid-of the textures from the previous level BGs and load up the new ones effectively.
Diniesh is just now adding a whole slew of stuff in T$$anonymous$$ that allows you to load his atlases on the fly only when you need them (BUT IT WILL HICCUP, as discussed here), but there's really no real way in unity to get rid of the then unused items!!!
Do you anims run smoothly with AsyncLevelLoad? $$anonymous$$ine glitch still :S
in fact i have not had a chance to try allowSceneActivation yet !
but yes, unfortunately for me everything still glitches (and I assume it's the case when adding allowSceneActivation)
i think Unity is plain not good at underlying strea$$anonymous$$g in of files (except audio, which is perfect)
Unfortunately I am not an expert in this issue: I can't make a statement like "with game engines X, Y, Z performance is thus, and with native iOS apps performance is thus...". I do know that I was always able to make native iOS apps smooth as silk one way or another, and I observe as a consumer that many games see$$anonymous$$gly stream large things in, as a matter of course, while an animation is playing or the like.
(then again it is true that many major famous titles, on Wii and such, indeed hiccup all over the place, during loading scenes.)