Beispiel #1
0
        /// <summary>
        /// Creates a smoothed AnimationCurve from either the tween type, or custom AnimationCurve, to use to tween the variable.
        /// </summary>
        private void SetupCurves()
        {
            m_AnimationCurves = new AnimationCurve[ValueLength()];
            Keyframe[][] keyframes = new Keyframe[ValueLength()][];

            if (m_TweenType == Tween.TweenType.Custom)
            {
                for (int i = 0; i < ValueLength(); i++)
                {
                    keyframes[i] = m_CustomCurve.keys;
                }
            }
            else
            {
                float[][] source = Tween.GetAnimCurveKeys(m_TweenType);

                for (int i = 0; i < ValueLength(); i++)
                {
                    keyframes[i] = new Keyframe[source.Length];

                    for (int j = 0; j < keyframes[i].Length; j++)
                    {
                        keyframes[i][j].time  = source[j][0];
                        keyframes[i][j].value = source[j][1];
                    }
                }
            }

            for (int i = 0; i < ValueLength(); i++)
            {
                for (int j = 0; j < keyframes[i].Length; j++)
                {
                    keyframes[i][j].value *= GetValue(true, i) - GetValue(false, i);
                    keyframes[i][j].value += GetValue(false, i);
                    keyframes[i][j].time  *= m_Duration;
                }

                m_AnimationCurves[i] = new AnimationCurve(keyframes[i]);

                if (m_CustomCurve == null)
                {
                    for (int j = 0; j < keyframes[i].Length; j++)
                    {
                        m_AnimationCurves[i].SmoothTangents(j, 0f);
                    }
                }
            }
        }
Beispiel #2
0
        private void SetupCurves()
        {
            m_AnimationCurves = new AnimationCurve[ValueLength()];
            m_Keyframes       = new Keyframe[ValueLength()][];

            if (m_TweenType == Tween.TweenType.Custom)
            {
                for (int i = 0; i < ValueLength(); i++)
                {
                    m_Keyframes[i] = m_CustomCurve.keys;
                }
            }
            else
            {
                GetKeys(Tween.GetAnimCurveKeys(m_TweenType));
            }

            for (int i = 0; i < ValueLength(); i++)
            {
                for (int j = 0; j < m_Keyframes[i].Length; j++)
                {
                    m_Keyframes[i][j].value *= GetValue(true, i) - GetValue(false, i);
                    m_Keyframes[i][j].value += GetValue(false, i);
                    m_Keyframes[i][j].time  *= m_Duration;
                }

                m_AnimationCurves[i] = new AnimationCurve(m_Keyframes[i]);

                if (m_CustomCurve == null)
                {
                    for (int j = 0; j < m_Keyframes[i].Length; j++)
                    {
                        m_AnimationCurves[i].SmoothTangents(j, 0f);
                    }
                }
            }
        }