Animating Tiled texture

Author: Joachim Ante

Description
This script animates a texture containing tiles of an animation. You can give it a framerate to determine the speed of the animation and set how many tiles on x, y there are.

Usage
Attach this script to the object that has a material with the tiled texture. To avoid distortion, the proportions of the object must be the same as the proportions of each tile (eg 1:2 for the sheet below).

Here is an example of how to lay out a texture for it (Thanks to BigBrainz for providing it):

(Leo Nogueira) Adding a simple image with multiple rows for testing purposes and a modified version of the C# Script:

CSharp - SpritSheet.cs
This is just a CSharp version of the AnimatedTextureUV.js above.

CSharp - SpritSheetNG.cs
The CSharp version of the script was not working with multiple rows so i made some changes.

CSharp - AnimateTiledTexture
A version using coroutines. Slightly faster since it doesn't update every frame and only sets the texture scale once.

CSharp - AnimateTiledTexture Extended By Bric Rogers (LITE3D)
An extended version of the AnimatedTiledTexture which adds a few advanced features.
 * Scale - Scale the texture on the 3D object.
 * Offset - Your texture will by default be centered on the 3D object. Use this to offset the texture
 * Buffer - If your texture has grid lines or if some tiles extend into others, you can use this to buffer out unwanted artifacts
 * PlayOnce - The animation will only be played one time through
 * DisableUponCompletion - The objects renderer will be disabled when the animation is completed
 * EnableEvents - Enable this if you want an event fired when the animation is completed
 * PlayOnEnable - The animation will begin playing when the object is enabled
 * NewMaterialInstance - Will create a copy of the material. This is useful if you want several AnimatedTiledTextures using the same material but playing them at different times.

The following is an example of how to use the events:

CSharp - AnimateSpriteSheet.cs
This one will cycle through sheets from TOP LEFT to BOTTOM RIGHT regardless of size. The two simple scripts above did not seem to either follow top-left-bottom-right or work when sheets got larger than the one they were tested on.

Since many games rely on waiting for Coroutines to finish, the variable RunTimeInSeconds is supplied, so a script can do a WaitForSeconds when waiting for it to return.