Anonymous Anonymous - 5 months ago
158 0

No description

C#

TimedFade

public class TimedFade : MonoBehaviour {
    public float fadeTime;
    public float displayTime;

    private SpriteRenderer sprite;
    private float timer;
    private float minimum = 0.0f;
    private float maximum = 1f;
    private bool fadeIn;

    // Use this for initialization
    void Start () {
        sprite = GetComponent<SpriteRenderer>();
        timer = Time.time;
	}

    // Update is called once per frame
    void Update()
    {
        float t = (Time.time - timer) / fadeTime;

        sprite.color = new Color(1f, 1f, 1f, Mathf.SmoothStep(maximum, minimum, t));        
    }
}