public UIEasePosition(RectTransform transform, Vector2 to, float duration, TimelineEaseType easeType) :
     base(easeType, duration)
 {
     _ref  = transform;
     _from = new Vector2(transform.localPosition.x, transform.localPosition.y);
     _to   = to;
 }
Esempio n. 2
0
 public TimelineEaseAction(TimelineEaseType easeType, float duration)
 {
     _easeType = easeType;
     _duration = duration;
 }
Esempio n. 3
0
        private static float Step(TimelineEaseType esType, float t)
        {
            switch (esType)
            {
            case TimelineEaseType.Quad:
            case TimelineEaseType.QuadIn:       return(t * t);

            case TimelineEaseType.QuadOut:      return(t * (2 - t));

            case TimelineEaseType.QuadInOut:    return((t *= 2) < 1 ? .5f * t * t : .5f * (1 - (t - 1) * (t - 3)));

            case TimelineEaseType.Cubic:
            case TimelineEaseType.CubicIn:      return(t * t * t);

            case TimelineEaseType.CubicOut:     return((t -= 1) * t * t + 1);

            case TimelineEaseType.CubicInOut:   return((t *= 2) < 1 ? .5f * t * t * t : .5f * ((t -= 2) * t * t + 2));

            case TimelineEaseType.Quart:
            case TimelineEaseType.QuartIn:      return(t * t * t * t);

            case TimelineEaseType.QuartOut:     return(1 - (t -= 1) * t * t * t);

            case TimelineEaseType.QuartInOut:   return((t *= 2) < 1 ? .5f * t * t * t * t : .5f * (2 - (t -= 2) * t * t * t));

            case TimelineEaseType.Quint:
            case TimelineEaseType.QuintIn:      return(t * t * t * t * t);

            case TimelineEaseType.QuintOut:     return((t -= 1) * t * t * t * t + 1);

            case TimelineEaseType.QuintInOut:   return((t *= 2) < 1 ? .5f * t * t * t * t * t : .5f * ((t -= 2) * t * t * t * t + 2));

            case TimelineEaseType.Sine:
            case TimelineEaseType.SineIn:       return(1 - (float)Math.Cos(t * HalfPi));

            case TimelineEaseType.SineOut:      return((float)Math.Sin(t * HalfPi));

            case TimelineEaseType.SineInOut:    return(.5f * (1 - (float)Math.Cos(t * Pi)));

            case TimelineEaseType.Expo:
            case TimelineEaseType.ExpoIn:       return((float)Math.Exp(7 * (t - 1)));

            case TimelineEaseType.ExpoOut:      return(1 - (float)Math.Exp(-7 * t));

            case TimelineEaseType.ExpoInOut:    return((t *= 2) < 1 ? .5f * (float)Math.Exp(7 * (t - 1)) : .5f * (2 - (float)Math.Exp(-7 * (t - 1))));

            case TimelineEaseType.Circ:
            case TimelineEaseType.CircIn:       return(1 - (float)Math.Sqrt(1 - t * t));

            case TimelineEaseType.CircOut:      return((float)Math.Sqrt(1 - (t -= 1) * t));

            case TimelineEaseType.CircInOut:    return((t *= 2) < 1 ? .5f * (1 - (float)Math.Sqrt(1 - t * t)) : .5f * ((float)Math.Sqrt(1 - (t -= 2) * t) + 1));

            case TimelineEaseType.Back:
            case TimelineEaseType.BackIn:       return(t * t * (2.70158f * t - 1.70158f));

            case TimelineEaseType.BackOut:      return((t -= 1) * t * (2.70158f * t + 1.70158f) + 1);

            case TimelineEaseType.BackInOut:    return((t *= 2) < 1 ? .5f * (t * t * (3.5949095f * t - 2.5949095f)) : .5f * ((t -= 2) * t * (3.5949095f * t + 2.5949095f) + 2));

            case TimelineEaseType.Elastic:
            case TimelineEaseType.ElasticIn:    return((float)(-Math.Exp(7 * (t -= 1)) * Math.Sin((t - 0.075) * 20.9439510239)));

            case TimelineEaseType.ElasticOut:   return((float)(Math.Exp(-7 * t) * Math.Sin((t - 0.075) * 20.9439510239) + 1));

            case TimelineEaseType.ElasticInOut: return((t *= 2) < 1 ? (float)(-.5 * Math.Exp(7 * (t -= 1)) * Math.Sin((t - 0.1125) * 13.962634016)) : (float)(Math.Exp(-7 * (t -= 1)) * Math.Sin((t - 0.1125) * 13.962634016) * .5 + 1));

            case TimelineEaseType.Bounce:
            case TimelineEaseType.BounceIn:     return(1 - Step(TimelineEaseType.BounceOut, 1 - t));

            case TimelineEaseType.BounceOut:    return(t < 0.363636363636f ? 7.5625f * t * t : t < 0.727272727273f ? 7.5625f * (t -= 0.545454545455f) * t + .75f : t < 0.909090909091f ? 7.5625f * (t -= 0.818181818182f) * t + .9375f : 7.5625f * (t -= 0.954545454545f) * t + .984375f);

            case TimelineEaseType.BounceInOut:  return((t *= 2) < 1 ? .5f * (1 - Step(TimelineEaseType.BounceOut, 1 - t)) : .5f * (Step(TimelineEaseType.BounceOut, t - 1) + 1));
            }

            return(t);
        }
 public void EasePosition(Vector2 to, float duration, TimelineEaseType easeType = TimelineEaseType.Linear)
 {
     _timeline.AppendAction(new UIEasePosition(_rectTransform, to, duration, easeType));
 }
 public UIEaseSize(RectTransform transform, float duration, TimelineEaseType easeType) :
     base(easeType, duration)
 {
     _ref = transform;
 }