private void FillPropertyGroup(ref EditorCurveBinding?[] propertyGroup, EditorCurveBinding lastBinding, string propertyGroupName, ref List <AnimationWindowCurve> curvesCache)
        {
            EditorCurveBinding binding = lastBinding;

            binding.isPhantom = true;
            if (!propertyGroup[0].HasValue)
            {
                binding.propertyName = propertyGroupName + ".x";
                AnimationWindowCurve item = new AnimationWindowCurve(this.animationClip, binding, this.GetEditorCurveValueType(binding))
                {
                    selectionBinding = this
                };
                curvesCache.Add(item);
            }
            if (!propertyGroup[1].HasValue)
            {
                binding.propertyName = propertyGroupName + ".y";
                AnimationWindowCurve curve2 = new AnimationWindowCurve(this.animationClip, binding, this.GetEditorCurveValueType(binding))
                {
                    selectionBinding = this
                };
                curvesCache.Add(curve2);
            }
            if (!propertyGroup[2].HasValue)
            {
                binding.propertyName = propertyGroupName + ".z";
                AnimationWindowCurve curve3 = new AnimationWindowCurve(this.animationClip, binding, this.GetEditorCurveValueType(binding))
                {
                    selectionBinding = this
                };
                curvesCache.Add(curve3);
            }
        }
Пример #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();
        }
        private void FillPropertyGroup(ref EditorCurveBinding?[] propertyGroup, EditorCurveBinding lastBinding, string propertyGroupName, ref List <AnimationWindowCurve> curvesCache)
        {
            EditorCurveBinding editorCurveBinding = lastBinding;

            editorCurveBinding.isPhantom = true;
            if (!propertyGroup[0].HasValue)
            {
                editorCurveBinding.propertyName = propertyGroupName + ".x";
                AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(this.animationClip, editorCurveBinding, this.GetEditorCurveValueType(editorCurveBinding));
                animationWindowCurve.selectionBinding = this;
                curvesCache.Add(animationWindowCurve);
            }
            if (!propertyGroup[1].HasValue)
            {
                editorCurveBinding.propertyName = propertyGroupName + ".y";
                AnimationWindowCurve animationWindowCurve2 = new AnimationWindowCurve(this.animationClip, editorCurveBinding, this.GetEditorCurveValueType(editorCurveBinding));
                animationWindowCurve2.selectionBinding = this;
                curvesCache.Add(animationWindowCurve2);
            }
            if (!propertyGroup[2].HasValue)
            {
                editorCurveBinding.propertyName = propertyGroupName + ".z";
                AnimationWindowCurve animationWindowCurve3 = new AnimationWindowCurve(this.animationClip, editorCurveBinding, this.GetEditorCurveValueType(editorCurveBinding));
                animationWindowCurve3.selectionBinding = this;
                curvesCache.Add(animationWindowCurve3);
            }
        }
Пример #4
0
        private List <AnimationWindowKeyframe> GetKeys(PropertyModification[] modifications)
        {
            var keys = new List <AnimationWindowKeyframe>();

            EditorCurveBinding[] bindings = AnimationWindowUtility.PropertyModificationsToEditorCurveBindings(modifications, state.activeRootGameObject, state.activeAnimationClip);
            if (bindings.Length == 0)
            {
                return(keys);
            }

            for (int i = 0; i < state.allCurves.Count; ++i)
            {
                AnimationWindowCurve curve = state.allCurves[i];
                if (Array.Exists(bindings, binding => curve.binding.Equals(binding)))
                {
                    int keyIndex = curve.GetKeyframeIndex(state.time);
                    if (keyIndex >= 0)
                    {
                        keys.Add(curve.m_Keyframes[keyIndex]);
                    }
                }
            }

            return(keys);
        }
Пример #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)
                    {
                        // 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);
        }
        public static AnimationWindowCurve BestMatchForPaste(EditorCurveBinding binding, List <AnimationWindowCurve> clipboardCurves, List <AnimationWindowCurve> targetCurves)
        {
            AnimationWindowCurve result;

            foreach (AnimationWindowCurve current in targetCurves)
            {
                if (current.binding == binding)
                {
                    result = current;
                    return(result);
                }
            }
            using (List <AnimationWindowCurve> .Enumerator enumerator2 = targetCurves.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    AnimationWindowCurve targetCurve = enumerator2.Current;
                    if (targetCurve.binding.propertyName == binding.propertyName)
                    {
                        if (!clipboardCurves.Exists((AnimationWindowCurve clipboardCurve) => clipboardCurve.binding == targetCurve.binding))
                        {
                            result = targetCurve;
                            return(result);
                        }
                    }
                }
            }
            result = null;
            return(result);
        }
Пример #7
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);
     }
 }
Пример #8
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);
        }
        private List <AnimationWindowKeyframe> GetKeys(PropertyModification[] modifications)
        {
            List <AnimationWindowKeyframe> list = new List <AnimationWindowKeyframe>();

            EditorCurveBinding[]           array = AnimationWindowUtility.PropertyModificationsToEditorCurveBindings(modifications, this.state.activeRootGameObject, this.state.activeAnimationClip);
            List <AnimationWindowKeyframe> result;

            if (array.Length == 0)
            {
                result = list;
            }
            else
            {
                for (int i = 0; i < this.state.allCurves.Count; i++)
                {
                    AnimationWindowCurve curve = this.state.allCurves[i];
                    if (Array.Exists <EditorCurveBinding>(array, (EditorCurveBinding binding) => curve.binding.Equals(binding)))
                    {
                        int keyframeIndex = curve.GetKeyframeIndex(this.state.time);
                        if (keyframeIndex >= 0)
                        {
                            list.Add(curve.m_Keyframes[keyframeIndex]);
                        }
                    }
                }
                result = list;
            }
            return(result);
        }
Пример #10
0
        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);
                }
            }
        }
 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();
 }
        private void FillPropertyGroup(ref EditorCurveBinding?[] propertyGroup, EditorCurveBinding lastBinding, string propertyGroupName, ref List <AnimationWindowCurve> curvesCache)
        {
            var newBinding = lastBinding;

            newBinding.isPhantom = true;
            if (!propertyGroup[0].HasValue)
            {
                newBinding.propertyName = propertyGroupName + ".x";
                AnimationWindowCurve curve = new AnimationWindowCurve(animationClip, newBinding, GetEditorCurveValueType(newBinding));
                curve.selectionBinding = this;
                curvesCache.Add(curve);
            }

            if (!propertyGroup[1].HasValue)
            {
                newBinding.propertyName = propertyGroupName + ".y";
                AnimationWindowCurve curve = new AnimationWindowCurve(animationClip, newBinding, GetEditorCurveValueType(newBinding));
                curve.selectionBinding = this;
                curvesCache.Add(curve);
            }

            if (!propertyGroup[2].HasValue)
            {
                newBinding.propertyName = propertyGroupName + ".z";
                AnimationWindowCurve curve = new AnimationWindowCurve(animationClip, newBinding, GetEditorCurveValueType(newBinding));
                curve.selectionBinding = this;
                curvesCache.Add(curve);
            }
        }
Пример #13
0
        public List <AnimationWindowHierarchyNode> CreateTreeFromCurves()
        {
            List <AnimationWindowHierarchyNode> list  = new List <AnimationWindowHierarchyNode>();
            List <AnimationWindowCurve>         list2 = new List <AnimationWindowCurve>();

            AnimationWindowCurve[] array = this.state.allCurves.ToArray();
            for (int i = 0; i < array.Length; i++)
            {
                AnimationWindowCurve animationWindowCurve  = array[i];
                AnimationWindowCurve animationWindowCurve2 = (i >= array.Length - 1) ? null : array[i + 1];
                list2.Add(animationWindowCurve);
                bool flag  = animationWindowCurve2 != null && AnimationWindowUtility.GetPropertyGroupName(animationWindowCurve2.propertyName) == AnimationWindowUtility.GetPropertyGroupName(animationWindowCurve.propertyName);
                bool flag2 = animationWindowCurve2 != null && animationWindowCurve.path.Equals(animationWindowCurve2.path) && animationWindowCurve.type == animationWindowCurve2.type;
                if (i == array.Length - 1 || !flag || !flag2)
                {
                    if (list2.Count > 1)
                    {
                        list.Add(this.AddPropertyGroupToHierarchy(list2.ToArray(), (AnimationWindowHierarchyNode)this.m_RootItem));
                    }
                    else
                    {
                        list.Add(this.AddPropertyToHierarchy(list2[0], (AnimationWindowHierarchyNode)this.m_RootItem));
                    }
                    list2.Clear();
                }
            }
            return(list);
        }
Пример #14
0
        protected override void RenameEnded()
        {
            string name         = base.GetRenameOverlay().name;
            string originalName = base.GetRenameOverlay().originalName;

            if (name != originalName)
            {
                Undo.RecordObject(this.state.activeAnimationClip, "Rename Curve");
                AnimationWindowCurve[] curves = this.m_RenamedNode.curves;
                for (int i = 0; i < curves.Length; i++)
                {
                    AnimationWindowCurve animationWindowCurve = curves[i];
                    string             newPath        = this.RenamePath(animationWindowCurve.path, name);
                    EditorCurveBinding renamedBinding = AnimationWindowUtility.GetRenamedBinding(animationWindowCurve.binding, newPath);
                    if (AnimationWindowUtility.CurveExists(renamedBinding, this.state.allCurves.ToArray()))
                    {
                        Debug.LogWarning("Curve already exists, renaming cancelled.");
                    }
                    else
                    {
                        AnimationWindowUtility.RenameCurvePath(animationWindowCurve, renamedBinding, animationWindowCurve.clip);
                    }
                }
            }
            this.m_RenamedNode = null;
        }
Пример #15
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);
            }
        }
 public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time)
 {
     if (state.activeCurves.Count > 0)
     {
         using (List <AnimationWindowCurve> .Enumerator enumerator = state.activeCurves.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 AnimationWindowCurve current = enumerator.Current;
                 AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
             }
         }
     }
     else
     {
         using (List <AnimationWindowCurve> .Enumerator enumerator = state.allCurves.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 AnimationWindowCurve current = enumerator.Current;
                 AnimationWindowUtility.AddKeyframeToCurve(state, current, time);
             }
         }
     }
 }
 public static AnimationWindowCurve BestMatchForPaste(EditorCurveBinding binding, List <AnimationWindowCurve> curves)
 {
     using (List <AnimationWindowCurve> .Enumerator enumerator = curves.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             AnimationWindowCurve current = enumerator.Current;
             if (current.binding == binding)
             {
                 return(current);
             }
         }
     }
     using (List <AnimationWindowCurve> .Enumerator enumerator = curves.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             AnimationWindowCurve current = enumerator.Current;
             if (current.binding.propertyName == binding.propertyName)
             {
                 return(current);
             }
         }
     }
     if (curves.Count == 1)
     {
         return(curves[0]);
     }
     return((AnimationWindowCurve)null);
 }
Пример #18
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);
            }
        }
        public List <AnimationWindowHierarchyNode> CreateTreeFromCurves()
        {
            List <AnimationWindowHierarchyNode> windowHierarchyNodeList  = new List <AnimationWindowHierarchyNode>();
            List <AnimationWindowCurve>         animationWindowCurveList = new List <AnimationWindowCurve>();

            AnimationWindowCurve[] array = this.state.allCurves.ToArray();
            for (int index = 0; index < array.Length; ++index)
            {
                AnimationWindowCurve animationWindowCurve1 = array[index];
                AnimationWindowCurve animationWindowCurve2 = index >= array.Length - 1 ? (AnimationWindowCurve)null : array[index + 1];
                animationWindowCurveList.Add(animationWindowCurve1);
                bool flag1 = animationWindowCurve2 != null && AnimationWindowUtility.GetPropertyGroupName(animationWindowCurve2.propertyName) == AnimationWindowUtility.GetPropertyGroupName(animationWindowCurve1.propertyName);
                bool flag2 = animationWindowCurve2 != null && animationWindowCurve1.path.Equals(animationWindowCurve2.path) && animationWindowCurve1.type == animationWindowCurve2.type;
                if (index == array.Length - 1 || !flag1 || !flag2)
                {
                    if (animationWindowCurveList.Count > 1)
                    {
                        windowHierarchyNodeList.Add((AnimationWindowHierarchyNode)this.AddPropertyGroupToHierarchy(animationWindowCurveList.ToArray(), (AnimationWindowHierarchyNode)this.m_RootItem));
                    }
                    else
                    {
                        windowHierarchyNodeList.Add((AnimationWindowHierarchyNode)this.AddPropertyToHierarchy(animationWindowCurveList[0], (AnimationWindowHierarchyNode)this.m_RootItem));
                    }
                    animationWindowCurveList.Clear();
                }
            }
            return(windowHierarchyNodeList);
        }
Пример #20
0
        public void GoToNextKeyframe(PropertyModification[] modifications)
        {
            EditorCurveBinding[] bindings = AnimationWindowUtility.PropertyModificationsToEditorCurveBindings(modifications, state.activeRootGameObject, state.activeAnimationClip);
            if (bindings.Length == 0)
            {
                return;
            }

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

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

            float newTime = AnimationWindowUtility.GetNextKeyframeTime(curves.ToArray(), time.time, state.clipFrameRate);

            SetCurrentTime(state.SnapToFrame(newTime, AnimationWindowState.SnapMode.SnapToClipFrame));

            state.Repaint();
        }
Пример #21
0
        public List <AnimationWindowHierarchyNode> CreateTreeFromCurves()
        {
            List <AnimationWindowHierarchyNode> list  = new List <AnimationWindowHierarchyNode>();
            List <AnimationWindowCurve>         list2 = new List <AnimationWindowCurve>();

            AnimationWindowCurve[] curveArray = this.state.allCurves.ToArray();
            for (int i = 0; i < curveArray.Length; i++)
            {
                AnimationWindowCurve item   = curveArray[i];
                AnimationWindowCurve curve2 = (i >= (curveArray.Length - 1)) ? null : curveArray[i + 1];
                list2.Add(item);
                bool flag  = (curve2 != null) && (AnimationWindowUtility.GetPropertyGroupName(curve2.propertyName) == AnimationWindowUtility.GetPropertyGroupName(item.propertyName));
                bool flag2 = ((curve2 != null) && item.path.Equals(curve2.path)) && (item.type == curve2.type);
                if (((i == (curveArray.Length - 1)) || !flag) || !flag2)
                {
                    if (list2.Count > 1)
                    {
                        list.Add(this.AddPropertyGroupToHierarchy(list2.ToArray(), (AnimationWindowHierarchyNode)base.m_RootItem));
                    }
                    else
                    {
                        list.Add(this.AddPropertyToHierarchy(list2[0], (AnimationWindowHierarchyNode)base.m_RootItem));
                    }
                    list2.Clear();
                }
            }
            return(list);
        }
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (UnityEditor.AnimationMode.InAnimationMode() && (curve.rootGameObject != null))
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     return(curve.Evaluate(state.currentTime - curve.timeOffset));
 }
 public AnimationWindowKeyframe(AnimationWindowCurve curve, Keyframe key)
 {
     this.time          = key.time;
     this.value         = (object)key.value;
     this.curve         = curve;
     this.m_InTangent   = key.inTangent;
     this.m_OutTangent  = key.outTangent;
     this.m_TangentMode = key.tangentMode;
 }
Пример #24
0
 public AnimationWindowKeyframe(AnimationWindowKeyframe key)
 {
     this.time          = key.time;
     this.value         = key.value;
     this.curve         = key.curve;
     this.m_InTangent   = key.m_InTangent;
     this.m_OutTangent  = key.m_OutTangent;
     this.m_TangentMode = key.m_TangentMode;
     this.m_curve       = key.m_curve;
 }
Пример #25
0
 // Retrieve current value.  If bindings are available and value is animated, use bindings to get value.
 // Otherwise, evaluate AnimationWindowCurve at current time.
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (state.previewing && curve.rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     else
     {
         return(curve.Evaluate(state.currentTime));
     }
 }
Пример #26
0
 private void DeleteKeysAtCurrentTime(List <AnimationWindowCurve> curves)
 {
     using (List <AnimationWindowCurve> .Enumerator enumerator = curves.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             AnimationWindowCurve current = enumerator.Current;
             current.RemoveKeyframe(this.state.time);
             this.state.SaveCurve(current);
         }
     }
 }
Пример #27
0
 public static bool CurveExists(EditorCurveBinding binding, AnimationWindowCurve[] curves)
 {
     for (int i = 0; i < curves.Length; i++)
     {
         AnimationWindowCurve animationWindowCurve = curves[i];
         if (binding.propertyName == animationWindowCurve.binding.propertyName && binding.type == animationWindowCurve.binding.type && binding.path == animationWindowCurve.binding.path)
         {
             return(true);
         }
     }
     return(false);
 }
 public void RemoveCurve(AnimationWindowCurve curve)
 {
     Undo.RegisterCompleteObjectUndo(this.m_ActiveAnimationClip, "Remove Curve");
     if (curve.isPPtrCurve)
     {
         AnimationUtility.SetObjectReferenceCurve(this.m_ActiveAnimationClip, curve.binding, null);
     }
     else
     {
         AnimationUtility.SetEditorCurve(this.m_ActiveAnimationClip, curve.binding, null);
     }
 }
        public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, Type type, AnimationKeyTime time)
        {
            AnimationWindowKeyframe animationWindowKeyframe = curve.FindKeyAtTime(time);
            AnimationWindowKeyframe result;

            if (animationWindowKeyframe != null)
            {
                animationWindowKeyframe.value = value;
                result = animationWindowKeyframe;
            }
            else
            {
                AnimationWindowKeyframe animationWindowKeyframe2 = null;
                if (curve.isPPtrCurve)
                {
                    animationWindowKeyframe2       = new AnimationWindowKeyframe();
                    animationWindowKeyframe2.time  = time.time;
                    animationWindowKeyframe2.value = value;
                    animationWindowKeyframe2.curve = curve;
                    curve.AddKeyframe(animationWindowKeyframe2, time);
                }
                else if (type == typeof(bool) || type == typeof(float))
                {
                    animationWindowKeyframe2 = new AnimationWindowKeyframe();
                    AnimationCurve animationCurve = curve.ToAnimationCurve();
                    Keyframe       key            = new Keyframe(time.time, (float)value);
                    if (type == typeof(bool))
                    {
                        AnimationUtility.SetKeyLeftTangentMode(ref key, AnimationUtility.TangentMode.Constant);
                        AnimationUtility.SetKeyRightTangentMode(ref key, AnimationUtility.TangentMode.Constant);
                        AnimationUtility.SetKeyBroken(ref key, true);
                        animationWindowKeyframe2.m_TangentMode = key.tangentMode;
                        animationWindowKeyframe2.m_InTangent   = float.PositiveInfinity;
                        animationWindowKeyframe2.m_OutTangent  = float.PositiveInfinity;
                    }
                    else
                    {
                        int num = animationCurve.AddKey(key);
                        if (num != -1)
                        {
                            CurveUtility.SetKeyModeFromContext(animationCurve, num);
                            animationWindowKeyframe2.m_TangentMode = animationCurve[num].tangentMode;
                        }
                    }
                    animationWindowKeyframe2.time  = time.time;
                    animationWindowKeyframe2.value = value;
                    animationWindowKeyframe2.curve = curve;
                    curve.AddKeyframe(animationWindowKeyframe2, time);
                }
                result = animationWindowKeyframe2;
            }
            return(result);
        }
        public List <AnimationWindowHierarchyNode> CreateTreeFromCurves()
        {
            List <AnimationWindowHierarchyNode> nodes = new List <AnimationWindowHierarchyNode>();
            List <AnimationWindowCurve>         singlePropertyCurves = new List <AnimationWindowCurve>();

            AnimationWindowCurve[]       curves     = state.allCurves.ToArray();
            AnimationWindowHierarchyNode parentNode = (AnimationWindowHierarchyNode)m_RootItem;
            SerializedObject             so         = null;

            for (int i = 0; i < curves.Length; i++)
            {
                AnimationWindowCurve curve = curves[i];

                if (!state.ShouldShowCurve(curve))
                {
                    continue;
                }

                AnimationWindowCurve nextCurve = i < curves.Length - 1 ? curves[i + 1] : null;

                if (curve.isSerializeReferenceCurve && state.activeRootGameObject != null)
                {
                    var animatedObject = AnimationUtility.GetAnimatedObject(state.activeRootGameObject, curve.binding);
                    if (animatedObject != null && (so == null || so.targetObject != animatedObject))
                    {
                        so = new SerializedObject(animatedObject);
                    }
                }

                singlePropertyCurves.Add(curve);

                bool areSameGroup       = nextCurve != null && AnimationWindowUtility.GetPropertyGroupName(nextCurve.propertyName) == AnimationWindowUtility.GetPropertyGroupName(curve.propertyName);
                bool areSamePathAndType = nextCurve != null && curve.path.Equals(nextCurve.path) && curve.type == nextCurve.type;

                // We expect curveBindings to come sorted by propertyname
                // So we compare curve vs nextCurve. If its different path or different group (think "scale.xyz" as group), then we know this is the last element of such group.
                if (i == curves.Length - 1 || !areSameGroup || !areSamePathAndType)
                {
                    if (singlePropertyCurves.Count > 1)
                    {
                        nodes.Add(AddPropertyGroupToHierarchy(singlePropertyCurves.ToArray(), parentNode, so));
                    }
                    else
                    {
                        nodes.Add(AddPropertyToHierarchy(singlePropertyCurves[0], parentNode, so));
                    }
                    singlePropertyCurves.Clear();
                }
            }

            return(nodes);
        }