I'm about to do some 2D animations. Currently I use a plane with a texture on it, and change the texture via
I'm curious if it's possible to store all the sprites I need in one file and do something like this:
The big texture contains all the animation states/sprites but only part of it is seen on the Plane surface. Then we 'move' the texture inside the Plane by x pixels so other content is visible. I have a lot of animations and loading every one as a separate Texture2D doesn't seem like the best solution. Thanks in advance
asked Feb 21 '12 at 12:45 AM
use animation sheet like this
and script is
If you are using the same material multiple places, then going to a "texture atlas" solution will likely reduce draw calls and potentially improve performance. There are a number of different scripts around that implement this functionality both on UnityAnswers and in the Wiki. They animate the UV coordinates of the material. Here is one link:
Note third-party tools like EZGUI and probably NGUI automate the process of creating animated textures and building the atlas. That is, the frames exist as individual textures in the editor, but the tools build a single atlas/texture which is used at runtime.
To to be clear, in order to get a significant win out of this, you need to have multiple animations using the same animation sheet (and therefore they both would have exactly the same material).