Пример #1
0
        private IEnumerator RunFadeVolume(VolumeFadeParameters parameters)
        {
            float t;

            t = 0;

            float frameRate;

            frameRate = (Application.targetFrameRate > 0) ? Application.targetFrameRate : 60;

            float step;

            step = 1 / (frameRate * parameters.Duration);

            this.Volume = parameters.From;

            while (t < 1)
            {
                yield return(null);

                t           = Mathf.Clamp(t + step, 0, 1);
                this.Volume = Quadratic.EaseInOut(parameters.From, parameters.To, t);
            }

            if (parameters.Completion != null)
            {
                parameters.Completion(this);
            }
        }
Пример #2
0
        internal static float Ease(Type ease, float t, float duration)
        {
            switch (ease)
            {
            case Type.Linear:
                return(Linear.EaseNone(t, duration));

            case Type.BackIn:
                return(Back.EaseIn(t, duration));

            case Type.BackOut:
                return(Back.EaseOut(t, duration));

            case Type.BackInOut:
                return(Back.EaseInOut(t, duration));

            case Type.BounceIn:
                return(Bounce.EaseIn(t, duration));

            case Type.BounceOut:
                return(Bounce.EaseOut(t, duration));

            case Type.BounceInOut:
                return(Bounce.EaseInOut(t, duration));

            case Type.CircIn:
                return(Circular.EaseIn(t, duration));

            case Type.CircOut:
                return(Circular.EaseOut(t, duration));

            case Type.CircInOut:
                return(Circular.EaseInOut(t, duration));

            case Type.CubicIn:
                return(Cubic.EaseIn(t, duration));

            case Type.CubicOut:
                return(Cubic.EaseOut(t, duration));

            case Type.CubicInOut:
                return(Cubic.EaseInOut(t, duration));

            case Type.ElasticIn:
                return(Elastic.EaseIn(t, duration));

            case Type.ElasticOut:
                return(Elastic.EaseOut(t, duration));

            case Type.ElasticInOut:
                return(Elastic.EaseInOut(t, duration));

            case Type.Punch:
                return(Elastic.Punch(t, duration));

            case Type.ExpoIn:
                return(Exponential.EaseIn(t, duration));

            case Type.ExpoOut:
                return(Exponential.EaseOut(t, duration));

            case Type.ExpoInOut:
                return(Exponential.EaseInOut(t, duration));

            case Type.QuadIn:
                return(Quadratic.EaseIn(t, duration));

            case Type.QuadOut:
                return(Quadratic.EaseOut(t, duration));

            case Type.QuadInOut:
                return(Quadratic.EaseInOut(t, duration));

            case Type.QuartIn:
                return(Quartic.EaseIn(t, duration));

            case Type.QuartOut:
                return(Quartic.EaseOut(t, duration));

            case Type.QuartInOut:
                return(Quartic.EaseInOut(t, duration));

            case Type.QuintIn:
                return(Quintic.EaseIn(t, duration));

            case Type.QuintOut:
                return(Quintic.EaseOut(t, duration));

            case Type.QuintInOut:
                return(Quintic.EaseInOut(t, duration));

            case Type.SineIn:
                return(Sinusoidal.EaseIn(t, duration));

            case Type.SineOut:
                return(Sinusoidal.EaseOut(t, duration));

            case Type.SineInOut:
                return(Sinusoidal.EaseInOut(t, duration));

            default:
                return(Linear.EaseNone(t, duration));
            }
        }