예제 #1
0
        // UnityEditor.CurveUtility.cs (c) Unity Technologies
        public static void UpdateTangentsFromMode(AnimationCurve curve, int index)
        {
            if (index < 0 || index >= curve.length)
            {
                return;
            }
            Keyframe key = curve [index];

            if (key.GetKeyTangentMode(0) == TangentMode.Linear && index >= 1)
            {
                key.inTangent = CalculateLinearTangent(curve, index, index - 1);
                curve.MoveKey(index, key);
            }
            if (key.GetKeyTangentMode(1) == TangentMode.Linear && index + 1 < curve.length)
            {
                key.outTangent = CalculateLinearTangent(curve, index, index + 1);
                curve.MoveKey(index, key);
            }
            if (key.GetKeyTangentMode(0) != TangentMode.Smooth && key.GetKeyTangentMode(1) != TangentMode.Smooth)
            {
                return;
            }
            curve.SmoothTangents(index, 0.0f);
        }
예제 #2
0
 public static void SetKeyTangentMode(this Keyframe key, int leftRight, TangentMode mode)
 {
     if (leftRight == 0)
     {
         key.tangentMode &= -7;
         key.tangentMode |= (int)((int)mode << 1);
     }
     else
     {
         key.tangentMode &= -25;
         key.tangentMode |= (int)((int)mode << 3);
     }
     if (key.GetKeyTangentMode(leftRight) != mode)
     {
         Debug.Log("bug");
     }
 }