Пример #1
0
        private static void UpdateTangentsFromMode(AnimationCurve curve, int index)
        {
            if (index < 0 || index >= curve.length)
            {
                return;
            }
            Keyframe key = curve[index];

            if (CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Linear && index >= 1)
            {
                key.inTangent = CurveUtility.CalculateLinearTangent(curve, index, index - 1);
                curve.MoveKey(index, key);
            }
            if (CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Linear && index + 1 < curve.length)
            {
                key.outTangent = CurveUtility.CalculateLinearTangent(curve, index, index + 1);
                curve.MoveKey(index, key);
            }
            if (CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Smooth || CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Smooth)
            {
                curve.SmoothTangents(index, 0f);
            }
        }