GetKeyRightTangentMode() static private method

static private GetKeyRightTangentMode ( Keyframe key ) : TangentMode
key UnityEngine.Keyframe
return TangentMode
        // Move me to CurveEditor.cs
        public static void SetKeyModeFromContext(AnimationCurve curve, int keyIndex)
        {
            Keyframe key           = curve[keyIndex];
            bool     broken        = false;
            bool     smoothTangent = false;

            if (keyIndex > 0)
            {
                if (AnimationUtility.GetKeyBroken(curve[keyIndex - 1]))
                {
                    broken = true;
                }
                TangentMode prevTangentMode = AnimationUtility.GetKeyRightTangentMode(curve[keyIndex - 1]);
                if (prevTangentMode == TangentMode.ClampedAuto || prevTangentMode == TangentMode.Auto)
                {
                    smoothTangent = true;
                }
            }
            if (keyIndex < curve.length - 1)
            {
                if (AnimationUtility.GetKeyBroken(curve[keyIndex + 1]))
                {
                    broken = true;
                }
                TangentMode nextTangentMode = AnimationUtility.GetKeyLeftTangentMode(curve[keyIndex + 1]);
                if (nextTangentMode == TangentMode.ClampedAuto || nextTangentMode == TangentMode.Auto)
                {
                    smoothTangent = true;
                }
            }

            AnimationUtility.SetKeyBroken(ref key, broken);

            if (broken && !smoothTangent)
            {
                if (keyIndex > 0)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref key, AnimationUtility.GetKeyRightTangentMode(curve[keyIndex - 1]));
                }
                if (keyIndex < curve.length - 1)
                {
                    AnimationUtility.SetKeyRightTangentMode(ref key, AnimationUtility.GetKeyLeftTangentMode(curve[keyIndex + 1]));
                }

                // Keys at boundaries.  Make sure left and right tangent modes are the same.
                if (keyIndex == 0)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref key, AnimationUtility.GetKeyRightTangentMode(key));
                }
                if (keyIndex == curve.length - 1)
                {
                    AnimationUtility.SetKeyRightTangentMode(ref key, AnimationUtility.GetKeyLeftTangentMode(key));
                }
            }
            else
            {
                // If both neighbors or only neighbor are set to TangentMode.Auto or TangentMode.ClampedAuto, set new key to this mode as well.
                // If there are no neighbors, set new key to TangentMode.ClampedAuto.
                // Otherwise, fall back to TangentMode.Free.
                TangentMode mode = TangentMode.Free;
                if ((keyIndex == 0 || AnimationUtility.GetKeyRightTangentMode(curve[keyIndex - 1]) == TangentMode.ClampedAuto) &&
                    (keyIndex == curve.length - 1 || AnimationUtility.GetKeyLeftTangentMode(curve[keyIndex + 1]) == TangentMode.ClampedAuto))
                {
                    mode = TangentMode.ClampedAuto;
                }
                else if ((keyIndex == 0 || AnimationUtility.GetKeyRightTangentMode(curve[keyIndex - 1]) == TangentMode.Auto) &&
                         (keyIndex == curve.length - 1 || AnimationUtility.GetKeyLeftTangentMode(curve[keyIndex + 1]) == TangentMode.Auto))
                {
                    mode = TangentMode.Auto;
                }

                AnimationUtility.SetKeyLeftTangentMode(ref key, mode);
                AnimationUtility.SetKeyRightTangentMode(ref key, mode);
            }

            curve.MoveKey(keyIndex, key);
        }
        public void UpdateTangentsFromMode(int index, int componentIndex)
        {
            AnimationCurve curve = this.GetCurve(componentIndex);

            if ((index >= 0) && (index < curve.length))
            {
                Keyframe key = curve[index];
                if ((AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Linear) && (index >= 1))
                {
                    key.inTangent = this.CalculateLinearTangent(index, index - 1, componentIndex);
                    curve.MoveKey(index, key);
                }
                if ((AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Linear) && ((index + 1) < curve.length))
                {
                    key.outTangent = this.CalculateLinearTangent(index, index + 1, componentIndex);
                    curve.MoveKey(index, key);
                }
                if ((AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto) || (AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto))
                {
                    float num = this.CalculateSmoothTangent(index, componentIndex);
                    key.outTangent = num;
                    key.inTangent  = num;
                    curve.MoveKey(index, key);
                }
            }
        }