Advertisement
AndrewRosyaev

Effect.cs

May 21st, 2016
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Effect : MonoBehaviour
  5. {
  6.     public Gradient gradient;
  7.     float time;
  8.     public float LifeTime;
  9.     public float ScaleModifier;
  10.  
  11.     void Awake ()
  12.     {
  13.         transform.rotation = transform.rotation * Quaternion.Euler (0,0,Random.Range(0,360));
  14.     }
  15.  
  16.     void Update ()
  17.     {
  18.         time += Time.deltaTime;
  19.         transform.GetComponent<MeshRenderer> ().material.SetColor ("_TintColor",gradient.Evaluate(time/LifeTime));
  20.         transform.localScale += new Vector3 (ScaleModifier/2, ScaleModifier/2, ScaleModifier);
  21.         if (time / LifeTime > 1)
  22.         {
  23.             Destroy (gameObject);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement