Beispiel #1
0
 public void ChangeColor(float duration, Color color0, Color color1, CurtainChangeHandler handler = null)
 {
     if (!isChanging)
     {
         isChanging = true;
         StartCoroutine(Change(duration, color0, color1, handler));
     }
 }
Beispiel #2
0
    IEnumerator Change(float duration, Color color0, Color color1, CurtainChangeHandler handler = null)
    {
        float time = 0f;

        while (time < duration)
        {
            float t = time / duration;
            image.color = Color.Lerp(color0, color1, t);

            time += Time.unscaledDeltaTime;
            yield return(null);
        }
        image.color = color1;
        isChanging  = false;
        if (handler != null)
        {
            handler();
        }
    }