Advertisement
Munchy2007

screenfader8

May 25th, 2016
4,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1.     public static void FadeIn(float delayBefore = 0, float delayAfter = 0, System.Action callback = null)
  2.     {
  3.         if (callback == null) callback = DefaultCallback;
  4.         group.gameObject.SetActive(true);
  5.         StopActiveFades();
  6.         fadeInCR = instance.StartCoroutine(instance.FadeInCoRoutine(delayBefore, delayAfter,callback));
  7.     }
  8.  
  9.     IEnumerator FadeInCoRoutine(float delayBefore, float delayAfter, System.Action callback)
  10.     {
  11.         yield return new WaitForSeconds(delayBefore);
  12.         while (group.alpha > 0)
  13.         {
  14.             group.alpha = Mathf.MoveTowards(group.alpha, 0f, instance.speed * Time.deltaTime);
  15.             yield return null;
  16.         }
  17.         yield return new WaitForSeconds(delayAfter);
  18.         if (callback != null) callback();
  19.  
  20.         group.gameObject.SetActive(false);
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement