Exemplo n.º 1
0
 private void AnimationTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (OnAnimationUpdate != null)
     {
         OnAnimationUpdate.Invoke(this, e);
     }
 }
Exemplo n.º 2
0
    public static IEnumerator AnimateValue(float from, float to, float duration, Interpolator interpolator, OnAnimationUpdate oau)
    {
        float startTime = Time.time;

        while (Time.time - startTime <= duration)
        {
            float value;
            if (interpolator != null)
            {
                value = (from + (to - from) * interpolator((Time.time - startTime) / duration));
            }
            else
            {
                value = (from + (to - from) * ((Time.time - startTime) / duration));
            }
            if (oau != null)
            {
                oau(value);
            }
            yield return(new WaitForEndOfFrame());
        }
        if (oau != null)
        {
            oau(to);
        }
    }