Guest User

tf1

a guest
Feb 7th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. var colorStart : Color = Color.red;
  2. var colorEnd : Color = Color.green;
  3. var duration : float = 1.0;
  4. var elapsed: float = 0.0;
  5. var finished : boolean = false;
  6. var animDurationInFrames : float = 0.4;
  7.  
  8.  
  9. function Update () {
  10.  
  11. if (elapsed < duration && finished == false) {
  12. renderer.material.color = Color.Lerp (colorStart, colorEnd, elapsed);
  13. } else {
  14. finished = true;
  15. }
  16.  
  17. if (finished == true) {
  18. renderer.material.color = Color.Lerp (colorEnd, colorStart, elapsed);
  19. }
  20.  
  21. if (gameObject.renderer.enabled && gameObject.renderer.enabled == true) {
  22. elapsed = elapsed + (Time.deltaTime / animDurationInFrames);
  23. }
  24.  
  25. if (gameObject.renderer.enabled == false) {
  26. elapsed = 0.0;
  27. finished = false;
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment