Mecanim sprite sheet animation UV

  • Hello,

    I have been trying to understand how to scale a secondary image properly whenever you use a Sprite Sheet animation from mecanim in a SpriteRenderer.

    In my example I want to render a fire effect over my character sprite. The animation of the main texture of the sprite is managed by an animator. My problem is that the fire effect looks like it is scaled to the size of the full sprite sheet of the animation, not as the current frame as I would like.
    Is there a way to get the proper UV comming from sprite sheet animations managed by mecanim ?


  • The big problem with Texture Atlas is that Unity doesn't allow to specify the good UV coordonate within the shader.

    They are an alternative way to use sprite sheet.

    For example, if we use this sprite sheet ( 512x512 )


    And use the MainTexture, it would do exactly the same as your example.

    But, if we use NewTexture instead, you can manipulate the whole texture as a single sprite.



    Than, for use with Mecanim,
    use this line, on the material parameter Sprite Sheet Frame UV, you won't see the sprite as a standard texture atlas, but's it's work


    Don't forget to turn the key on constant like this


    It's a strange manipulation but for the moment, since Unity doesn't allow to do that directly by shader, it's the only way, but it's work great as you can see.

    Hope it's help,
    If you have any other questions, don't hesitate.

  • Hello,

    Thank you for the clear example. This is exactly what I wanted to do.
    So it is how I feared ... I will have to reimport all my animations using your trick.

    Well if Unity adds a way to use proper UV, having a source component using it in Shadero would be a great addition :-)
    Keep up the good work! Your product is great!


Looks like your connection to Vetasoft Assets was lost, please wait while we try to reconnect.