I want to have a plane that shows an animated Gif as it's texture, so essentially it will be a movie. Can I apply an animated Gif as a texture? If so, does it apply like a normal texture? Note: I know about Movie Textures, but don't want to use them

  • 4
    \$\begingroup\$ the GIF file format was subject to patents for really long time and the graphics industry has not a really good support for this format since it's not a really good format for this purpose ( animation ) and there are other ways to do almost the same thing with some simple sprites putted in series in a single image and used in sequence when you want to animate your character. \$\endgroup\$ – user827992 Aug 26 '12 at 15:24
  • \$\begingroup\$ @user827992 So I would do something like described here where I am constantly changing the texture? \$\endgroup\$ – Liam McInroy Aug 26 '12 at 15:25
  • 1
    \$\begingroup\$ that's more or less what a sprite is used for, answers.unity3d.com/questions/45530/animated-sprites.html or google.com/#q=unity+3d+animated+sprites or forum.unity3d.com/threads/…! \$\endgroup\$ – user827992 Aug 26 '12 at 15:30

Short answer is no. You will need to convert the GIF to an atlased texture (a single 2D image that has all the GIF frames in it) and then cycle the UV coordinates on a textured quad to change which frame is currently visible. This is not particularly hard to do, and there are existing sprite animation packages for Unity that can do most of it for you (you'll likely have to create the atlas yourself, or at least split the GIF into separate PNG images for each frame to use an existing atlas creator).

| improve this answer | |
  • \$\begingroup\$ Thanks, and what object would I use to do this? \$\endgroup\$ – Liam McInroy Aug 26 '12 at 16:40
  • \$\begingroup\$ You can animate the UVs of a mesh component manually. There are packages in the Asset Store that do all of this for you, but I don't have experience with any of them so I can't make a recommendation as to which to use. \$\endgroup\$ – Sean Middleditch Aug 26 '12 at 16:44
  • \$\begingroup\$ I have no personal experience with it, but I hear ShoeBox is pretty slick. It supports converting animated GIFs to Unity texture atlases. \$\endgroup\$ – postgoodism Aug 27 '12 at 4:33

I made this script. Just attach it to the gameobject, for example a plane and then just fill the frames array with all the frames of the gif in the inspector.

public class AnimGif : MonoBehaviour {

    [SerializeField] private Texture2D[] frames;
    [SerializeField] private  float fps = 10.0f;

    private Material mat;

    void Start () {
        mat = GetComponent<Renderer> ().material;

    void Update () {
        int index = (int)(Time.time * fps);
        index = index % frames.Length;
        mat.mainTexture = frames[index]; // usar en planeObjects
        //GetComponent<RawImage> ().texture = frames [index];
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.