Esempio n. 1
0
 public static void SaveModifiedCurve(AnimationWindowCurve curve, AnimationClip clip)
 {
     curve.m_Keyframes.Sort((AnimationWindowKeyframe a, AnimationWindowKeyframe b) => a.time.CompareTo(b.time));
     if (curve.isPPtrCurve)
     {
         ObjectReferenceKeyframe[] array = curve.ToObjectCurve();
         if (array.Length == 0)
         {
             array = null;
         }
         AnimationUtility.SetObjectReferenceCurve(clip, curve.binding, array);
     }
     else
     {
         AnimationCurve animationCurve = curve.ToAnimationCurve();
         if (animationCurve.keys.Length == 0)
         {
             animationCurve = null;
         }
         else
         {
             QuaternionCurveTangentCalculation.UpdateTangentsFromMode(animationCurve, clip, curve.binding);
         }
         AnimationUtility.SetEditorCurve(clip, curve.binding, animationCurve);
     }
 }
 public void SaveCurve(AnimationWindowCurve curve)
 {
     curve.m_Keyframes.Sort((AnimationWindowKeyframe a, AnimationWindowKeyframe b) => a.time.CompareTo(b.time));
     Undo.RegisterCompleteObjectUndo(this.m_ActiveAnimationClip, "Edit Curve");
     if (curve.isPPtrCurve)
     {
         ObjectReferenceKeyframe[] array = curve.ToObjectCurve();
         if (array.Length == 0)
         {
             array = null;
         }
         AnimationUtility.SetObjectReferenceCurve(this.m_ActiveAnimationClip, curve.binding, array);
     }
     else
     {
         AnimationCurve animationCurve = curve.ToAnimationCurve();
         if (animationCurve.keys.Length == 0)
         {
             animationCurve = null;
         }
         else
         {
             QuaternionCurveTangentCalculation.UpdateTangentsFromMode(animationCurve, this.m_ActiveAnimationClip, curve.binding);
         }
         AnimationUtility.SetEditorCurve(this.m_ActiveAnimationClip, curve.binding, animationCurve);
     }
     this.Repaint();
 }
Esempio n. 3
0
        internal static IEnumerable <UndoPropertyModification> FindBestEulerHint(Quaternion rotation, AnimationClip clip, float time, Transform transform)
        {
            Vector3 euler = rotation.eulerAngles;

            var xCurve = AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(string.Empty, typeof(Transform), "localEulerAnglesRaw.x"));
            var yCurve = AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(string.Empty, typeof(Transform), "localEulerAnglesRaw.y"));
            var zCurve = AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(string.Empty, typeof(Transform), "localEulerAnglesRaw.z"));

            if (xCurve != null)
            {
                euler.x = xCurve.Evaluate(time);
            }
            if (yCurve != null)
            {
                euler.y = yCurve.Evaluate(time);
            }
            if (zCurve != null)
            {
                euler.z = zCurve.Evaluate(time);
            }

            euler = QuaternionCurveTangentCalculation.GetEulerFromQuaternion(rotation, euler);

            return(new[]
            {
                PropertyModificationToUndoPropertyModification(new PropertyModification {
                    target = transform, propertyPath = kLocalEulerHint + ".x", value = euler.x.ToString()
                }),
                PropertyModificationToUndoPropertyModification(new PropertyModification {
                    target = transform, propertyPath = kLocalEulerHint + ".y", value = euler.y.ToString()
                }),
                PropertyModificationToUndoPropertyModification(new PropertyModification {
                    target = transform, propertyPath = kLocalEulerHint + ".z", value = euler.z.ToString()
                })
            });
        }