Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Testing : MonoBehaviour {
  5.  
  6. public float interval; //Defines transition's duration.
  7. public float frames = 60.0f; //Defines how many frames uses the transition.
  8.  
  9. private Material material;
  10. private bool growing;
  11. private float time;
  12.  
  13. // Use this for initialization
  14. void Start () {
  15.  
  16. material = GetComponent<Renderer>().material;
  17. time = 0;
  18. growing = true;
  19.  
  20. }
  21.  
  22. // Update is called once per frame
  23. void Update () {
  24.  
  25. time += Time.deltaTime;
  26.  
  27. if (time >= interval/frames) {
  28.  
  29. time = 0;
  30. Color c = material.GetColor("_EmissionColor");
  31.  
  32. if (material.GetColor("_EmissionColor").b >= 1) growing = false;
  33. else if (material.GetColor("_EmissionColor").b <= 0) growing = true;
  34.  
  35. if (growing) {
  36. c.b += 1/frames;
  37. } else {
  38. c.b -= 1/frames;
  39. }
  40.  
  41. material.SetColor("_EmissionColor", c);
  42. }
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement