Exemple #1
0
        /// <summary>
        /// Generates an AnimationCurve based on input Ease Equation Method.
        /// </summary>
        /// <param name="equation">Enum of Ease Equation To use.</param>
        /// <param name="animCurve">AnimationCurve that contains converted results.</param>
        /// <param name="conversionProperties">Struct that defines various curve conversion properties.</param>
        /// <param name="debug">When true will log various debug statements.</param>
        public static void ConvertEaseEquationToCurve(EasingEquationsDouble.Equations equation, AnimationCurve animCurve, ConversionProperties conversionProperties, bool debug = false)
        {
            m_EaseMethod = ( Ease )Delegate.CreateDelegate(typeof(Ease), typeof(EasingEquationsDouble).GetMethod(equation.ToString()));

            List <Vector2> inPts = CreatePointsFromEaseEquation(conversionProperties, false);
            List <Vector2> ppPts = ConvertToAnimationCurve.Preprocess(inPts, conversionProperties.m_PreprocessMode, conversionProperties.m_PointDistance, conversionProperties.m_RdpError);

            if (debug)
            {
                Debug.LogFormat("ConvertEaseEquationToCurve: {0:D3} {1:D4} : {2}", ppPts.Count, inPts.Count, equation);
            }

            if (conversionProperties.m_UseCurveFit)
            {
                CubicBezier[] curves = CurveFit.Fit(ppPts, conversionProperties.m_FitError);
                if (debug)
                {
                    Debug.LogFormat("ConvertEaseEquationToCurve: {0} curves: {1}", equation, curves.Length);
                }
                ConvertToAnimationCurve.ConvertToAnimCurve(animCurve, conversionProperties, curves);
            }
            else
            {
                ConvertToAnimationCurve.ConvertToAnimCurve(animCurve, conversionProperties, ppPts, debug);
            }
        }