Created
September 7, 2015 20:51
-
-
Save FeniXb3/bb04e5601b9949ab03fe to your computer and use it in GitHub Desktop.
Small component for Unity3d that is responsible for looping texture on the gameobject. The gameobject that has uses this component needs a renderer with material that has a texture you want to use.
This file contains 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; | |
public class TextureOffsetController : MonoBehaviour | |
{ | |
public float speed = 0.05f; | |
private float position = 0.0f; | |
void Update() | |
{ | |
position += speed; | |
if (position > 1.0f) | |
{ | |
position -= 1.0f; | |
} | |
GetComponent<Renderer>().material.mainTextureOffset = new Vector2(0.0f, position); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment