Skip to content

BelalElhawary/ImGif

Repository files navigation

ImGif

GIF image player for Unity.

works with Image, RawImage and SpriteRenderer

tested on Linux x64, Windows x64, Android, WebGl

this library is using mgGif 'Gif parser for unity' to parse gif file byte array to list of texture2d

How to use

Download unity package and import it to your project

To add new Gif asset go to Assets/ImGif/Import

alt text

pick your file.gif image

alt text

this will create new asset file with the same name in your Assets folder

alt text

now you can add Gif or FixedGif Component to your GameObject and drag the gif asset file to the data field in the inspector

alt text

Components

Gif

uses Update function to loop for every texture in the array, first it will pick the first texture from the array and apply it to the target renderer then it will wait for a specific amount of time given in seconds after that will advance to the next texture.

Fixed Gif

uses FixedUpdate to update the texture on the target renderer which means delays should be in int value between each frame, you can set this value in the frame delay field.

Public methods

public void Play()

public void Stop()

public void PlayOnce()

Chose Renderer

Target your preferred Renderer from Render Target option in Gif component alt text

⚠️ Make sure you added the targeted component before running