texture animation

hey guys what is the best way to get an texture animated so what i mean is when i make an 2d texture animation i normaly export it to an gif format but that is not what i want becous the giff pulls down the resolution so it becomes verry uggley i can make it an avi or somthing like it that looks fine but how do i get or make an animated texture for unity on what format and i woud like to know how its done .thanks

To be able to use a MovieTexture in Unity, you'll need UnityPro. The native format of such a movie that is used by Unity is OGG Theora, but any or most standard video formats and files (AVI, MOV, MPG, ...) will be automatically converted on import. A workaround for very short movies (= a few seconds low-res) would be to import all single frames as normal textures, and then use a simple script to switch through them.

What I need is:

  • a plane (it should also work for other surfaces(spheres, cubes etc.))

  • an animated Texture(these with columns and rows, not a gif)

  • textures as PNG for transparency

  • be sure set the correct variables in the inspector for this:

    using UnityEngine;

    using System.Collections;

    public class TextureAnimationScript : MonoBehaviour
    {

     public int TilesX;
     public int TilesY;
     public float AnimationCyclesPerSecond;
    
     void Start ()
     {
     	renderer.material.mainTextureScale = new Vector2(1.0f / TilesX, 1.0f / TilesY);
     	StartCoroutine(ChangeOffSet());
     }
     
     IEnumerator ChangeOffSet ()
     {
     	for(int i = TilesY - 1; i > -1; i--)
     	{
     		for(int j = 0; j < TilesX; j++)
     		{
     			renderer.material.mainTextureOffset = new Vector2(1.0f / TilesX * j, 1.0f / TilesY * i);
     			yield return new WaitForSeconds(1.0f / (TilesX * TilesY * AnimationCyclesPerSecond));
     			if(i == 0 && j == TilesX - 1)
     			{
     				i = TilesY;
     			}
     		}
     	}
     }
    

    }

attach this script to a plane:

var frames : Texture2D;
var framesPerSecond = 10.0;

function Update () {
var index : int = Time.time * framesPerSecond;
index = index % frames.Length;
renderer.material.mainTexture = frames[index];
}

this is a javascript script