I'm working in Unity, and I'm finding that the animator isn't working for what I'm trying to do, in my 2D game. I want to build a specific animation, using sprite sheets, and be able to reuse the same animation with other sprites that are the same size and dimensions by cells. After some research, I find that it is impossible.

Instead, I'm trying to create my own animation script, but I don't understand how to tell Unity to draw only a section of the sprite. Something like in XNA, where you could render only a specific rectangle of a sprite using start and end coordinates.

How do I manually draw a part of a sprite sheet?

  • 3
    \$\begingroup\$ This is possible in Unity without duplicating the animation data, with a little hack. Effectively, you play animation A using spritesheetA, then in LateUpdate you swap each SpriteRenderer's Sprite to its analogue from spritesheetB. There was a Unity video on this technique; I'll post it as an answer if I can find it later, and elaborate on the details. This will let you use the full power of Unity's native animation system without having to write your own from scratch. \$\endgroup\$
    – DMGregory
    Commented Jul 22, 2016 at 12:05
  • \$\begingroup\$ You should try Spine or some other skeletal animation software. It has a skins capability that allows you to maintain the same bone animations, but swap and change skins as needed. I personally use Spine because it is simple, there are tutorials and it has a unity runtime that makes everything super simple. The downside is it does cost money, but the basic version gives you everything you need to make animations. The pro version just makes it easier and quicker. \$\endgroup\$
    – Savlon
    Commented Feb 26, 2018 at 10:25
  • \$\begingroup\$ use masks if you work on UI \$\endgroup\$
    – virtouso
    Commented Aug 5, 2018 at 8:54

1 Answer 1


I think there can be a simpler approach in which you can do this , and still use Unity Mecanim for the animation.


1) You can programatically assign texture 2D sprites from the image, and as it is a grid it wont be much difficult to do so. In the following answer the user has created his own sprite slicer and saved into the directory (optional else just save it in a variable). You don't need the whole code,just check the GetSprites() function and you will get the idea :)


2) Once you are able to do that, then maintain an Array of sprites, which you got from step 1.

3) Now you need to create an anim file of these sprites which can be plugged into mecanim. For this you need Unity's Set Curve function(check the link provided below). Once you have the clip its upto you whether to save it for future use or just have it in a variable for the current game instance only.


Hope this resolves your doubt :)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .