Skip to content

Instantly share code, notes, and snippets.

@naojitaniguchi
Created October 20, 2015 10:18
Show Gist options
  • Save naojitaniguchi/71e27e9d532afcdc9ee2 to your computer and use it in GitHub Desktop.
Save naojitaniguchi/71e27e9d532afcdc9ee2 to your computer and use it in GitHub Desktop.
Scroll texture in Unity
using UnityEngine;
using System.Collections;
public class ScrollTexture : MonoBehaviour {
public float scrollSpeed = 0.0004f ;
private Mesh mesh ;
// Use this for initialization
void Start () {
mesh = GetComponent<MeshFilter>().mesh ;
}
// Update is called once per frame
void Update () {
scroll();
}
void scroll(){
Vector2[] uvSwap = mesh.uv;
for (int i = 0 ; i < uvSwap.Length ; i ++)
{
uvSwap[i] += new Vector2( scrollSpeed * Time.deltaTime, scrollSpeed * Time.deltaTime );
}
mesh.uv = uvSwap;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment