-
-
Save alxcancado/1ae5e8225a635b3c1f2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.UI; | |
public class ColorFader : MonoBehaviour | |
{ | |
public float delay = 2; | |
void Start () { | |
StartCoroutine(Fade(delay)); | |
} | |
IEnumerator Fade(float duration) | |
{ | |
var comp = GetComponent<Image>(); | |
for (float timer = 0; timer < duration; timer += Time.deltaTime) | |
{ | |
//Debug.Log(timer/duration); | |
comp.color = Color.Lerp(Color.black,Color.clear,timer/duration); | |
yield return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment