Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class LifeTime : MonoBehaviour {
- private Color colorStart;
- private Color colorEnd;
- private float duration = 1.0f;
- private float startTime;
- void Awake() {
- colorStart = renderer.material.color;
- colorEnd = colorStart;
- colorEnd.a = 0;
- startTime = Time.time;
- }
- void Update () {
- float lerp = Mathf.PingPong (Time.time - startTime, duration) / duration;
- gameObject.renderer.material.color = Color.Lerp(colorStart, colorEnd, lerp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment