using UnityEngine;
using System.Collections;
public class classAnimateTiledTexture :MonoBehaviour
{
public int columns = 5;
public int rows = 3;
void Start()
{
StartCoroutine(updateTiling());
//set thetile size of the texture (in UV units), based on the rows and columns
Vector2 size = new Vector2(1f/ columns, 1f / rows);
renderer.sharedMaterial.SetTextureScale("_MainTex", size);
}
private IEnumerator updateTiling()
{
while(true)
{
for(int i = rows-1; i >-1; i--)
{
for(int j = 0; j<columns; j++)
{
Vector2 offset = new Vector2((float)j / columns,(float)i / rows);
renderer.sharedMaterial.SetTextureOffset("_MainTex",offset);
yield return new WaitForSeconds(1f);
}
}
}
}
}