GIF: Introduction
The GIF module provides you convenient tools to encode and decode GIF images. It allows you to record screen activities into a short clip, play the recorded clip and export it into a GIF image. In the other direction, it allows you to decode a GIF image into a playable animation clip, or an array of textures.
It also allows you to upload the GIF file to hosting sites like Giphy and finally share its URL to social networks. Effectively, this module helps you easily add the GIF sharing feature to your game, which allows the user to share animated GIF images of the gameplay, instead of still screenshots, to social networks including Facebook and Twitter. The following picture illustrates a typical workflow of such feature.
Here're some highlights of this module:
High performance, mobile-friendly GIF generator
- Low overhead screen/camera recorder
- GIF generation is done in native code (iOS and Android) on a separate thread to allow fast exporting while minimizing impact to the main thread. Export callbacks are still called from main thread though, so you can safely access Unity API in the callback handlers
Flexible, fully controllable process
- You have full control on the sizes, length, frame rate, loop mode and quality of the exported GIF
- You can also set the priority of the exporting thread to best suit your needs
High quality GIF
- Exported GIF employs GIF89a format and uses 256-color local palettes (one palette per frame)
- Frame image data is LWZ compressed
Works in Unity editor
- GIF exporting also works in the editor, mostly for testing purpose. On mobiles, the exporting is done in native code, while in editor it is done in managed code using an adapted version of the Moments plugin (see Acknowledgement)
Easy GIF sharing
- This module also provides Giphy API for uploading GIF images to Giphy, so that they can be shared and played on major social networks including Facebook and Twitter using the Giphy hosted URLs
Fast and flexible GIF decoding
- Fast GIF decoder written in native code (iOS and Android), thread controllable
- GIF can be decoded into a playable animation clip or an array of textures
- Flexible: decode the whole GIF image or just the first frame (useful for thumbnails) or any arbitrary number of frames
Acknowledgement
The recorder used in this module is adapted from the recorder of the Moments plugin by Chman (Thomas Hourdel). Also, in Unity editor, GIF generation is done using an adapted version of this plugin.