Exemple #1
0
        private static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject    activeRootGameObject = state.activeRootGameObject;
            AnimationClip activeAnimationClip  = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
            {
                AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, type);
                object currentValue = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);
                if (animationWindowCurve.length == 0)
                {
                    object value = null;
                    if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out value))
                    {
                        value = currentValue;
                    }
                    if (state.frame != 0)
                    {
                        AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                    }
                }
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
                state.SaveCurve(animationWindowCurve);
            }
        }
Exemple #2
0
        static void AddRotationKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles)
        {
            AnimationClip clip = state.activeAnimationClip;

            if ((clip.hideFlags & HideFlags.NotEditable) != 0)
            {
                return;
            }

            EditorCurveBinding[] additionalBindings = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, clip);

            // Add key at current frame
            for (int i = 0; i < 3; i++)
            {
                AnimationWindowCurve curve = new AnimationWindowCurve(clip, additionalBindings[i], type);

                if (state.addZeroFrame)
                {
                    // Is it a new curve?
                    if (curve.length == 0)
                    {
                        if (state.currentFrame != 0)
                        {
                            AnimationWindowUtility.AddKeyframeToCurve(curve, previousEulerAngles[i], type, AnimationKeyTime.Frame(0, clip.frameRate));
                        }
                    }
                }

                AnimationWindowUtility.AddKeyframeToCurve(curve, currentEulerAngles[i], type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));
                state.SaveCurve(curve);
            }
        }
        private static void AddRotationKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles)
        {
            AnimationClip activeAnimationClip = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
            {
                EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip);
                for (int i = 0; i < 3; i++)
                {
                    AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, array[i], type);
                    if (state.addZeroFrame)
                    {
                        if (animationWindowCurve.length == 0)
                        {
                            if (state.currentFrame != 0)
                            {
                                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, previousEulerAngles[i], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                            }
                        }
                    }
                    AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentEulerAngles[i], type, AnimationKeyTime.Frame(state.currentFrame, activeAnimationClip.frameRate));
                    state.SaveCurve(animationWindowCurve);
                }
            }
        }
Exemple #4
0
        static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, object previousValue, object currentValue)
        {
            AnimationClip clip = state.activeAnimationClip;

            if ((clip.hideFlags & HideFlags.NotEditable) != 0)
            {
                return;
            }

            AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type);

            // Add previous value at first frame on empty curves.
            if (state.addZeroFrame)
            {
                // Is it a new curve?
                if (curve.length == 0)
                {
                    if (state.currentFrame != 0)
                    {
                        // case 1373924
                        // In the case of a new curve, we also have to convert the previousValue to float for a discrete int
                        if (binding.isDiscreteCurve)
                        {
                            previousValue = UnityEngine.Animations.DiscreteEvaluationAttributeUtilities.ConvertDiscreteIntToFloat((int)previousValue);
                        }
                        AnimationWindowUtility.AddKeyframeToCurve(curve, previousValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
                    }
                }
            }

            // Add key at current frame.
            AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));

            state.SaveCurve(curve);
        }
Exemple #5
0
        static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, object previousValue, object currentValue)
        {
            AnimationClip clip = state.activeAnimationClip;

            if ((clip.hideFlags & HideFlags.NotEditable) != 0)
            {
                return;
            }

            AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type);

            // Add previous value at first frame on empty curves.
            if (state.addZeroFrame)
            {
                // Is it a new curve?
                if (curve.length == 0)
                {
                    if (state.currentFrame != 0)
                    {
                        AnimationWindowUtility.AddKeyframeToCurve(curve, previousValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
                    }
                }
            }

            // Add key at current frame.
            AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));

            state.SaveCurve(curve);
        }
 public static void CreateDefaultCurves(IAnimationRecordingState state, AnimationWindowSelectionItem selectionItem, EditorCurveBinding[] properties)
 {
     properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(selectionItem.animationClip, properties);
     EditorCurveBinding[] array = properties;
     for (int i = 0; i < array.Length; i++)
     {
         EditorCurveBinding binding = array[i];
         state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(selectionItem, binding));
     }
 }
        public static void CreateDefaultCurves(IAnimationRecordingState state, EditorCurveBinding[] properties)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(activeAnimationClip, properties);
            EditorCurveBinding[] array = properties;
            for (int i = 0; i < array.Length; i++)
            {
                EditorCurveBinding binding = array[i];
                state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, activeRootGameObject, binding));
            }
        }
Exemple #8
0
        static void ProcessAnimatorModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale)
        {
            AnimationClip clip = state.activeAnimationClip;

            if ((clip.hideFlags & HideFlags.NotEditable) != 0)
            {
                return;
            }

            float prevValue = value;

            object oValue;

            if (ValueFromPropertyModification(modification.currentValue, new EditorCurveBinding(), out oValue))
            {
                value = (float)oValue;
            }

            if (ValueFromPropertyModification(modification.previousValue, new EditorCurveBinding(), out oValue))
            {
                prevValue = (float)oValue;
            }

            value     = Mathf.Abs(scale) > Mathf.Epsilon ? value / scale : value;
            prevValue = Mathf.Abs(scale) > Mathf.Epsilon ? prevValue / scale : prevValue;

            var binding = new EditorCurveBinding();

            binding.propertyName = name;
            binding.path         = "";
            binding.type         = typeof(Animator);

            var prop = new PropertyModification();

            prop.target       = animator;
            prop.propertyPath = binding.propertyName;
            prop.value        = value.ToString();

            state.AddPropertyModification(binding, prop, modification.keepPrefabOverride);

            AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, typeof(float));

            if (state.addZeroFrame && state.currentFrame != 0 && curve.length == 0)
            {
                AnimationWindowUtility.AddKeyframeToCurve(curve, prevValue, typeof(float), AnimationKeyTime.Frame(0, clip.frameRate));
            }

            AnimationWindowUtility.AddKeyframeToCurve(curve, value, typeof(float), AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));

            state.SaveCurve(curve);
        }
 private static void AddRotationKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles)
 {
     AnimationClip activeAnimationClip = state.activeAnimationClip;
     if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
     {
         EditorCurveBinding[] bindingArray = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip);
         for (int i = 0; i < 3; i++)
         {
             AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, bindingArray[i], type);
             if ((curve.length == 0) && (state.frame != 0))
             {
                 AnimationWindowUtility.AddKeyframeToCurve(curve, previousEulerAngles[i], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
             }
             AnimationWindowUtility.AddKeyframeToCurve(curve, currentEulerAngles[i], type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
             state.SaveCurve(curve);
         }
     }
 }
Exemple #10
0
        static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject    root = state.activeRootGameObject;
            AnimationClip clip = state.activeAnimationClip;

            if ((clip.hideFlags & HideFlags.NotEditable) != 0)
            {
                return;
            }

            AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type);

            // Add key at current frame
            object currentValue = CurveBindingUtility.GetCurrentValue(root, binding);

            if (state.addZeroFrame)
            {
                // Is it a new curve?
                if (curve.length == 0)
                {
                    object oldValue = null;
                    if (!ValueFromPropertyModification(modification, binding, out oldValue))
                    {
                        oldValue = currentValue;
                    }

                    if (state.currentFrame != 0)
                    {
                        AnimationWindowUtility.AddKeyframeToCurve(curve, oldValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
                    }
                }
            }

            AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));

            state.SaveCurve(curve);
        }
 private static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
 {
     GameObject activeRootGameObject = state.activeRootGameObject;
     AnimationClip activeAnimationClip = state.activeAnimationClip;
     if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
     {
         AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, binding, type);
         object currentValue = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);
         if (curve.length == 0)
         {
             object outObject = null;
             if (!ValueFromPropertyModification(modification, binding, out outObject))
             {
                 outObject = currentValue;
             }
             if (state.frame != 0)
             {
                 AnimationWindowUtility.AddKeyframeToCurve(curve, outObject, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
             }
         }
         AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
         state.SaveCurve(curve);
     }
 }
Exemple #12
0
        private static void ProcessAnimatorModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale)
        {
            AnimationClip activeAnimationClip = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None)
            {
                float  num = value;
                object obj;
                if (AnimationRecording.ValueFromPropertyModification(modification.currentValue, default(EditorCurveBinding), out obj))
                {
                    value = (float)obj;
                }
                if (AnimationRecording.ValueFromPropertyModification(modification.previousValue, default(EditorCurveBinding), out obj))
                {
                    num = (float)obj;
                }
                value = ((Mathf.Abs(scale) <= Mathf.Epsilon) ? value : (value / scale));
                num   = ((Mathf.Abs(scale) <= Mathf.Epsilon) ? num : (num / scale));
                EditorCurveBinding binding = default(EditorCurveBinding);
                binding.propertyName = name;
                binding.path         = "";
                binding.type         = typeof(Animator);
                PropertyModification propertyModification = new PropertyModification();
                propertyModification.target       = animator;
                propertyModification.propertyPath = binding.propertyName;
                propertyModification.value        = value.ToString();
                state.AddPropertyModification(binding, propertyModification, modification.keepPrefabOverride);
                AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, typeof(float));
                if (state.addZeroFrame && state.currentFrame != 0 && animationWindowCurve.length == 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, num, typeof(float), AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, typeof(float), AnimationKeyTime.Frame(state.currentFrame, activeAnimationClip.frameRate));
                state.SaveCurve(animationWindowCurve);
            }
        }