Last active
December 20, 2015 10:31
-
-
Save Lorti/6116385 to your computer and use it in GitHub Desktop.
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; | |
using System.Collections; | |
public class AnimateMaterial : MonoBehaviour { | |
public float scrollSpeedU = 0.0f; | |
public float scrollSpeedV = 0.25f; | |
public float amplitudeU = 0.0f; | |
public float amplitudeV = 0.0f; | |
void Update() { | |
float offsetU = 0.0f; | |
float offsetV = 0.0f; | |
if(amplitudeU > 0.0f) { | |
offsetU = amplitudeU * Mathf.Sin(scrollSpeedU * Time.time); | |
} else { | |
offsetU = Time.time * scrollSpeedU; | |
} | |
if(amplitudeV > 0.0f) { | |
offsetV = amplitudeV * Mathf.Sin(scrollSpeedV * Time.time); | |
} else { | |
offsetV = Time.time * scrollSpeedV; | |
} | |
renderer.material.SetTextureOffset("_MainTex", new Vector2(offsetU, offsetV)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment