using UnityEngine;

public class TextureScroll : MonoBehaviour 
{
    Vector2 uvOffset = Vector2.zero;
    public Vector2 uvAnimationRate = Vector2.zero;

    public int materialIndex = 0;

    MeshRenderer thisRenderer;

    public string textureName = "_MainTex";

    void Start()
    {
        thisRenderer = GetComponent<MeshRenderer>();
    }

    void Update()
    {
        uvOffset += (uvAnimationRate * Time.deltaTime);

        if (thisRenderer.enabled)
        {
            thisRenderer.materials[materialIndex].SetTextureOffset(textureName, uvOffset);
        }
    }

}
