SFE_UVScrollerExtended.js 507 B

12345678910111213141516171819202122232425262728
  1. //This script scrolls the UV on an object (by offsetting its material).
  2. var velocityY:float = 0.0;
  3. var velocityX:float = 0.5;
  4. var matNumber:int=0;
  5. function Start()
  6. {
  7. if ( renderer )
  8. enabled = false;
  9. }
  10. function Update()
  11. {
  12. renderer.materials[matNumber].mainTextureOffset.y += velocityY * Time.deltaTime;
  13. renderer.materials[matNumber].mainTextureOffset.x += velocityX * Time.deltaTime;
  14. }
  15. function OnBecameVisible()
  16. {
  17. this.enabled = true;
  18. }
  19. function OnBecameInvisible()
  20. {
  21. this.enabled = false;
  22. }