예제 #1
0
        public static float Lerp(float t, LERP_TYPE lerpType)
        {
            switch (lerpType)
            {
            case LERP_TYPE.LINEAR:
                // Do nothing
                break;

            case LERP_TYPE.EASE_IN:
                t = EaseIn(t);
                break;

            case LERP_TYPE.EASE_OUT:
                t = EaseOut(t);
                break;

            case LERP_TYPE.EXPONENTIAL:
                t = Exponential(t);
                break;

            case LERP_TYPE.SMOOTHSTEP:
                t = Smoothstep(t);
                break;

            case LERP_TYPE.SMOOTHERSTEP:
                t = Smootherstep(t);
                break;
            }

            return(t);
        }
예제 #2
0
        /// <summary>
        /// Starts an animation state: Float
        /// </summary>
        /// <returns></returns>
        IEnumerator StartAnimation(Component component, string propertyName, float endValue, float duration, LERP_TYPE lerpType, UnityEngine.Events.UnityEvent actionOnEnd)
        {
            float interpolator = 0;
            float initialValue = GetPropertyValue <float>(component, propertyName);
            float curve;

            while (interpolator < 1)
            {
                interpolator += Time.deltaTime / duration;
                curve         = LerpUtils.Lerp(interpolator, lerpType);
                SetProperty(component, propertyName, Mathf.Lerp(initialValue, endValue, curve));
                yield return(null);
            }

            SetProperty(component, propertyName, endValue);

            if (actionOnEnd != null)
            {
                actionOnEnd.Invoke();
            }
        }