Created
October 20, 2015 10:18
-
-
Save naojitaniguchi/71e27e9d532afcdc9ee2 to your computer and use it in GitHub Desktop.
Scroll texture in Unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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