- Home /
Most efficient way to do 2D animation
I'm working on a project that requires a lot of large 2D looping animation. For example, one scene has 4 animations going at once, each about 30 frames each, and the frames themselves are large PNGs stored as 2048 compressed textures (the dimensions of the actual PNGs are larger than 2048).
My approach right now is to load each frame in from Resources and change the texture of the material to the new frame. This causes the animation to run very slowly on the first loop while the frames are being loaded. Is there a better way to do this? The animations can't be scaled down because our client wants the animations to be very high quality; in fact they're not even happy with the 2048 compressed textures. We considered storing the textures in the scene as a Texture 2D array instead of loading them from Resources, but were worried that this would increase the load time of the scene too much, as we cannot have a long delay betweens scenes.
Is there anything we can do to make the animations load faster and run more smoothly? The target device is iPad 2 and 3.
Isn't an iPad3 "only" about 2500px tall by 1500px wide? And displaying 4 scenes at once your ideal texture size is close to 1024x1024?
It sounds like the original compression, from the "actual PNGs," which are more than 2048 squared, might be causing the problem.
not to sound like a broken record, but you just need 2DToolkit for this, and all the work is done. it give you a "one draw call" paradigm where possible, it completely handles atlases etc etc, nothing is faster. if you can't do it with 2DT$$anonymous$$ you technically can't do it at the Unity3D level.
Surely what you're describing would be better as a video?
I'll definitely look into 2D Toolkit. As far as using videos, how would you do that? Since $$anonymous$$ovie Textures aren't supported for mobile devices, would I have to use something like Prime 31's Live Texture? Also, the animations have transparent parts and are layered on top of one another. Is it possible to accomplish that using videos?
Answer by sooshicat · Oct 06, 2012 at 05:03 PM
Honestly that sounds way wrong. I am not an expert but wouldn't it be better to have each animation as an animated gif, or as a flash movie with a transparent background, and just change the file as needed? Loading each frame of the animation in such massive files is ludicrous!
EDIT: Have realised that animated gifs can't be used in Unity. Refer to other comments
Is that possible with Unity? We had considered it originally but when I did a quick search it seemed like gifs weren't supported in Unity, and the only answer I found was to use a series of textures and cycle through them.
Hmm, did a bit of searching myself and it appears your right. However with textures the size you are talking about, your frame rate will be awful. I would look into 2Dtoolkit like previously suggested. There is also a good script to do what you are talking about here http://wiki.unity3d.com/index.php?title=Texture_swap_animator
There's another thread on this here http://answers.unity3d.com/questions/27859/animated-gif-and-audio-ins$$anonymous$$d-of-video.html
Answer by Venryx · Mar 03, 2014 at 08:01 PM
You could also try a script like the following, which makes use of Mono's System.Drawing library: http://wiki.unity3d.com/index.php/AnimatedGifDrawer
How heavy is this operation as opposed to using an animated sprite?
For anyone still looking at this question, the OP was more or less asking the impossible. I don't even know how Apple or Samsung would do full-screen (!!) totally non-compressed (!!!) transparent (!!!!) video (whatever you'd call it) WITH (not to mention) a whole game engine running at the same time. So it's all a bit of a confusion. Note that THIS ... http://answers.unity3d.com/questions/433609/hiccups-when-loading-images-from-resources-folder.html .. is probably very relevant if you're trying more modest problems involving loading large files. In a word, Unity only bothered figuring out audio strea$$anonymous$$g, not other file types. Hope it helps someone.
Your answer
Follow this Question
Related Questions
reset 2d animation(sprite sheet texture) 0 Answers
Best Practices on 2D Animation? 1 Answer
How change sprite animation texture?? 2 Answers
2d Sprite Sheet on characters ruined in unity 1 Answer
Custom Pivot Points in Sprite Editor 1 Answer