public AnimationWindowCurve(AnimationClip clip, EditorCurveBinding binding, Type valueType)
 {
     binding          = RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(binding, clip);
     this.m_Binding   = binding;
     this.m_ValueType = valueType;
     this.LoadKeyframes(clip);
 }
Exemple #2
0
        public override void ProcessCandidates()
        {
            BeginKeyModification();

            EditorCurveBinding[] bindings            = AnimationUtility.GetCurveBindings(m_CandidateClip);
            EditorCurveBinding[] objectCurveBindings = AnimationUtility.GetObjectReferenceCurveBindings(m_CandidateClip);

            List <AnimationWindowCurve> curves = new List <AnimationWindowCurve>();

            for (int i = 0; i < state.allCurves.Count; ++i)
            {
                AnimationWindowCurve curve           = state.allCurves[i];
                EditorCurveBinding   remappedBinding = RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(curve.binding, m_CandidateClip);
                if (Array.Exists(bindings, binding => remappedBinding.Equals(binding)) || Array.Exists(objectCurveBindings, binding => remappedBinding.Equals(binding)))
                {
                    curves.Add(curve);
                }
            }

            AnimationWindowUtility.AddKeyframes(state, curves, time);

            EndKeyModification();

            ClearCandidates();
        }
Exemple #3
0
        // Checks if a key already exists for this property
        static bool HasBinding(UnityEngine.Object target, PropertyModification modification, AnimationClip clip, out EditorCurveBinding binding)
        {
            var component     = target as Component;
            var playableAsset = target as IPlayableAsset;

            if (component != null)
            {
                var type = AnimationUtility.PropertyModificationToEditorCurveBinding(modification, component.gameObject, out binding);
                binding = RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(binding, clip);
                return(type != null);
            }

            if (playableAsset != null)
            {
                binding = EditorCurveBinding.FloatCurve(string.Empty, target.GetType(),
                                                        AnimatedParameterUtility.GetAnimatedParameterBindingName(target, modification.propertyPath));
            }
            else
            {
                binding = new EditorCurveBinding();
                return(false);
            }

            return(true);
        }
        public void Update(AnimationClip clip)
        {
            List <EditorCurveBinding> postfilter = new List <EditorCurveBinding>();
            var clipBindings = AnimationUtility.GetCurveBindings(clip);

            for (int i = 0; i < clipBindings.Length; i++)
            {
                var bind = clipBindings[i];
                if (!bind.propertyName.Contains("LocalRotation.w"))
                {
                    postfilter.Add(RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(bind, clip));
                }
            }
            bindings = postfilter.ToArray();

            curves = new AnimationCurve[bindings.Length];
            for (int i = 0; i < bindings.Length; i++)
            {
                curves[i] = AnimationUtility.GetEditorCurve(clip, bindings[i]);
            }

            objectBindings = AnimationUtility.GetObjectReferenceCurveBindings(clip);
            objectCurves   = new List <ObjectReferenceKeyframe[]>(objectBindings.Length);
            for (int i = 0; i < objectBindings.Length; i++)
            {
                objectCurves.Add(AnimationUtility.GetObjectReferenceCurve(clip, objectBindings[i]));
            }

            m_CurveDirty = false;
            m_KeysDirty  = true;

            version = version + 1;
        }
Exemple #5
0
        public void Update(AnimationClip clip)
        {
            List <EditorCurveBinding> list = new List <EditorCurveBinding>();

            EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(clip);
            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding editorCurveBinding = curveBindings[i];
                if (!editorCurveBinding.propertyName.Contains("LocalRotation.w"))
                {
                    list.Add(RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(editorCurveBinding, clip));
                }
            }
            this.bindings = list.ToArray();
            this.curves   = new AnimationCurve[this.bindings.Length];
            for (int j = 0; j < this.bindings.Length; j++)
            {
                this.curves[j] = AnimationUtility.GetEditorCurve(clip, this.bindings[j]);
            }
            this.objectBindings = AnimationUtility.GetObjectReferenceCurveBindings(clip);
            this.objectCurves   = new List <ObjectReferenceKeyframe[]>(this.objectBindings.Length);
            for (int k = 0; k < this.objectBindings.Length; k++)
            {
                this.objectCurves.Add(AnimationUtility.GetObjectReferenceCurve(clip, this.objectBindings[k]));
            }
            this.m_CurveDirty = false;
            this.m_KeysDirty  = true;
            this.version++;
        }
Exemple #6
0
        public AnimationWindowCurve(AnimationClip clip, EditorCurveBinding binding, System.Type valueType)
        {
            binding = RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(binding, clip);

            m_Binding         = binding;
            m_BindingHashCode = binding.GetHashCode();
            m_ValueType       = valueType;
            m_Clip            = clip;

            LoadKeyframes(clip);
        }
 public override void ProcessCandidates()
 {
     if (!(this.m_CandidateClip == null))
     {
         this.BeginKeyModification();
         EditorCurveBinding[]        curveBindings = AnimationUtility.GetCurveBindings(this.m_CandidateClip);
         EditorCurveBinding[]        objectReferenceCurveBindings = AnimationUtility.GetObjectReferenceCurveBindings(this.m_CandidateClip);
         List <AnimationWindowCurve> list = new List <AnimationWindowCurve>();
         for (int i = 0; i < this.state.allCurves.Count; i++)
         {
             AnimationWindowCurve animationWindowCurve = this.state.allCurves[i];
             EditorCurveBinding   remappedBinding      = RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(animationWindowCurve.binding, this.m_CandidateClip);
             if (Array.Exists <EditorCurveBinding>(curveBindings, (EditorCurveBinding binding) => remappedBinding.Equals(binding)) || Array.Exists <EditorCurveBinding>(objectReferenceCurveBindings, (EditorCurveBinding binding) => remappedBinding.Equals(binding)))
             {
                 list.Add(animationWindowCurve);
             }
         }
         AnimationWindowUtility.AddKeyframes(this.state, list.ToArray(), this.time);
         this.EndKeyModification();
         this.ClearCandidates();
     }
 }
Exemple #8
0
 private static void ProcessTemporaryKeys(AnimationClip clip)
 {
     if (!(clip == null))
     {
         bool flag = false;
         EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(clip);
         EditorCurveBinding[] array         = curveBindings;
         for (int i = 0; i < array.Length; i++)
         {
             EditorCurveBinding editorCurveBinding = array[i];
             if (!editorCurveBinding.propertyName.Contains("LocalRotation.w"))
             {
                 EditorCurveBinding binding = RotationCurveInterpolation.RemapAnimationBindingForRotationCurves(editorCurveBinding, clip);
                 flag |= AnimationTrackRecorder.ProcessCurveBinding(clip, binding);
             }
         }
         if (flag)
         {
             EditorUtility.SetDirty(clip);
         }
     }
 }