ScrollingUVs.cs 562 B

1234567891011121314151617181920
  1. using UnityEngine;
  2. using System.Collections;
  3. public class ScrollingUVs : MonoBehaviour
  4. {
  5. public int materialIndex = 0;
  6. public Vector2 uvAnimationRate = new Vector2( 1.0f, 0.0f );
  7. public string textureName = "_MainTex";
  8. Vector2 uvOffset = Vector2.zero;
  9. void LateUpdate()
  10. {
  11. uvOffset += ( uvAnimationRate * Time.deltaTime );
  12. if( GetComponent<Renderer>().enabled )
  13. {
  14. GetComponent<Renderer>().materials[ materialIndex ].SetTextureOffset( textureName, uvOffset );
  15. }
  16. }
  17. }