示例#1
0
    /// <summary>
    /// updates the color for a tween
    /// </summary>
    protected virtual void ColorUpdate(vp_UITween.Tween tween)
    {
        if (tween.Type != vp_UITween.vp_UITweenType.Color)
        {
            return;
        }

        if (tween.ElapsedTime < tween.Duration)
        {
            // lerp the color
            tween.CurrentColor = Color.Lerp(tween.StartColor, tween.EndColor, (tween.ElapsedTime / tween.Duration));

            // update the color on the object
            tween.ColorUpdate();

            // update the elapsed time
            tween.ElapsedTime += Time.deltaTime;

            return;
        }

        if (tween.CurrentColor != tween.EndColor)
        {
            tween.CurrentColor = tween.EndColor;
            tween.ColorUpdate();
        }

        // callback
        if (tween.Callback != null)
        {
            tween.Callback();
        }

        if (!tween.Handle.Custom)        // destroy the tween if no handle was provided
        {
            Instance.Tweens.Remove(tween.Handle);
        }
        else                                            // set to inactive if a handle was provided
        {
            tween.Handle.Active = false;
        }
    }