UnityEditor.AnimationUtility.Internal_CalculateLinearTangent C# (CSharp) Method

Internal_CalculateLinearTangent() private static method

private static Internal_CalculateLinearTangent ( AnimationCurve curve, int index, int toIndex ) : float
curve AnimationCurve
index int
toIndex int
return float
        private static float Internal_CalculateLinearTangent(AnimationCurve curve, int index, int toIndex)
        {
            Keyframe keyframe = curve[index];
            Keyframe keyframe2 = curve[toIndex];
            float a = keyframe.time - keyframe2.time;
            if (Mathf.Approximately(a, 0f))
            {
                return 0f;
            }
            Keyframe keyframe3 = curve[index];
            Keyframe keyframe4 = curve[toIndex];
            return ((keyframe3.value - keyframe4.value) / a);
        }

Usage Example

Beispiel #1
0
 private static void Internal_UpdateTangents(AnimationCurve curve, int index)
 {
     if (index >= 0 && index < curve.length)
     {
         Keyframe key = curve[index];
         if (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Linear && index >= 1)
         {
             key.inTangent = AnimationUtility.Internal_CalculateLinearTangent(curve, index, index - 1);
             curve.MoveKey(index, key);
         }
         if (AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Linear && index + 1 < curve.length)
         {
             key.outTangent = AnimationUtility.Internal_CalculateLinearTangent(curve, index, index + 1);
             curve.MoveKey(index, key);
         }
         if (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto || AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto)
         {
             AnimationUtility.Internal_CalculateAutoTangent(curve, index);
         }
         if (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Auto || AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Auto)
         {
             curve.SmoothTangents(index, 0f);
         }
         if (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Free && AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Free && !AnimationUtility.GetKeyBroken(key))
         {
             key.outTangent = key.inTangent;
             curve.MoveKey(index, key);
         }
         if (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Constant)
         {
             key.inTangent = float.PositiveInfinity;
             curve.MoveKey(index, key);
         }
         if (AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Constant)
         {
             key.outTangent = float.PositiveInfinity;
             curve.MoveKey(index, key);
         }
     }
 }
All Usage Examples Of UnityEditor.AnimationUtility::Internal_CalculateLinearTangent
AnimationUtility