Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Testing : MonoBehaviour {
- public float interval; //Defines transition's duration.
- public float frames = 60.0f; //Defines how many frames uses the transition.
- private Material material;
- private bool growing;
- private float time;
- // Use this for initialization
- void Start () {
- material = GetComponent<Renderer>().material;
- time = 0;
- growing = true;
- }
- // Update is called once per frame
- void Update () {
- time += Time.deltaTime;
- if (time >= interval/frames) {
- time = 0;
- Color c = material.GetColor("_EmissionColor");
- if (material.GetColor("_EmissionColor").b >= 1) growing = false;
- else if (material.GetColor("_EmissionColor").b <= 0) growing = true;
- if (growing) {
- c.b += 1/frames;
- } else {
- c.b -= 1/frames;
- }
- material.SetColor("_EmissionColor", c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement