Esempio n. 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);
            }
        }
Esempio n. 2
0
        static public T Begin <T>(GameObject go, float start, float offset, EasingEquationsDouble.Equations easeEquation, EasingGraphManager easingGraphManager) where T : EasingDrawer
        {
            T component = go.GetComponent <T>();

            if (null == component)
            {
                component = go.AddComponent <T>();
            }

            component.m_EasingGraphManager = easingGraphManager;
            component.m_Equation           = easeEquation;
            component.m_Start  = start;
            component.m_Offset = offset;
            component.enabled  = true;

            return(component);
        }
Esempio n. 3
0
        static public T Begin <T>(GameObject go, float start, float offset, float duration, EasingEquationsDouble.Equations easeEquation, Action <bool> onComplete = null) where T : TweenActionEase_RectTransformSlide
        {
            T component = go.GetComponent <T>();

            // If component doesn't exist add it
            if (null == component)
            {
                component = go.AddComponent <T>();
            }

            // Clamp duration
            if (duration < 0.1f)
            {
                duration = 0.1f;
            }

            component.m_Position   = go.transform.position;
            component.m_EaseMethod = ( Ease )Delegate.CreateDelegate(typeof(Ease), typeof(EasingEquationsDouble).GetMethod(easeEquation.ToString()));
            component.m_Timer      = 0f;
            component.m_Duration   = duration;
            component.m_Start      = start;
            component.m_Offset     = offset;

            component.m_OnComplete = onComplete;
            component.enabled      = true;

            return(component);
        }