Exemple #1
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 #3
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 #4
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++;
        }
 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 #6
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);
                }
            }
        }
 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));
     }
 }
Exemple #9
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 static void CreateDefaultCurves(AnimationWindowState state, EditorCurveBinding[] properties)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(state.activeAnimationClip, properties);
            foreach (EditorCurveBinding property in properties)
            {
                state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, activeRootGameObject, property));
            }
        }
Exemple #11
0
        public static UndoPropertyModification[] Process(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            if (activeRootGameObject == null)
            {
                return(modifications);
            }
            AnimationClip activeAnimationClip = state.activeAnimationClip;
            Animator      component           = activeRootGameObject.GetComponent <Animator>();

            if (!HasAnyRecordableModifications(activeRootGameObject, modifications))
            {
                return(modifications);
            }
            ProcessRotationModifications(state, ref modifications);
            List <UndoPropertyModification> list = new List <UndoPropertyModification>();

            for (int i = 0; i < modifications.Length; i++)
            {
                EditorCurveBinding   binding       = new EditorCurveBinding();
                PropertyModification previousValue = modifications[i].previousValue;
                System.Type          type          = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                if (type != null)
                {
                    if (((component != null) && component.isHuman) && ((binding.type == typeof(Transform)) && component.IsBoneTransform(previousValue.target as Transform)))
                    {
                        Debug.LogWarning("Keyframing for humanoid rig is not supported!", previousValue.target as Transform);
                    }
                    else
                    {
                        UnityEditor.AnimationMode.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                        EditorCurveBinding[] bindingArray = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (bindingArray != null)
                        {
                            for (int j = 0; j < bindingArray.Length; j++)
                            {
                                AddKey(state, bindingArray[j], type, FindPropertyModification(activeRootGameObject, modifications, bindingArray[j]));
                            }
                        }
                        else
                        {
                            AddKey(state, binding, type, previousValue);
                        }
                    }
                }
                else
                {
                    list.Add(modifications[i]);
                }
            }
            return(list.ToArray());
        }
Exemple #12
0
        public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            if ((UnityEngine.Object)activeRootGameObject == (UnityEngine.Object)null)
            {
                return(modifications);
            }
            AnimationClip activeAnimationClip = state.activeAnimationClip;
            Animator      component           = activeRootGameObject.GetComponent <Animator>();

            if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
            {
                return(modifications);
            }
            AnimationRecording.ProcessRotationModifications(state, ref modifications);
            List <UndoPropertyModification> propertyModificationList = new List <UndoPropertyModification>();

            for (int index1 = 0; index1 < modifications.Length; ++index1)
            {
                EditorCurveBinding   binding            = new EditorCurveBinding();
                PropertyModification previousValue      = modifications[index1].previousValue;
                System.Type          editorCurveBinding = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                if (editorCurveBinding != null && editorCurveBinding != typeof(Animator))
                {
                    if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.isHuman && (binding.type == typeof(Transform) && component.IsBoneTransform(previousValue.target as Transform)))
                    {
                        Debug.LogWarning((object)"Keyframing for humanoid rig is not supported!", (UnityEngine.Object)(previousValue.target as Transform));
                    }
                    else
                    {
                        AnimationMode.AddPropertyModification(binding, previousValue, modifications[index1].keepPrefabOverride);
                        EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (editorCurveBindingArray != null)
                        {
                            for (int index2 = 0; index2 < editorCurveBindingArray.Length; ++index2)
                            {
                                AnimationRecording.AddKey(state, editorCurveBindingArray[index2], editorCurveBinding, AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, editorCurveBindingArray[index2]));
                            }
                        }
                        else
                        {
                            AnimationRecording.AddKey(state, binding, editorCurveBinding, previousValue);
                        }
                    }
                }
                else
                {
                    propertyModificationList.Add(modifications[index1]);
                }
            }
            return(propertyModificationList.ToArray());
        }
Exemple #13
0
        public static void CreateDefaultCurves(AnimationWindowState state, EditorCurveBinding[] properties)
        {
            AnimationClip activeAnimationClip = state.m_ActiveAnimationClip;
            GameObject    rootGameObject      = state.m_RootGameObject;

            properties = RotationCurveInterpolation.ConvertRotationPropertiesToDefaultInterpolation(state.m_ActiveAnimationClip, properties);
            EditorCurveBinding[] array = properties;
            for (int i = 0; i < array.Length; i++)
            {
                EditorCurveBinding binding = array[i];
                state.SaveCurve(AnimationWindowUtility.CreateDefaultCurve(activeAnimationClip, rootGameObject, binding));
            }
        }
Exemple #14
0
 private void ChangeRotationInterpolation(object interpolationMode)
 {
     RotationCurveInterpolation.Mode mode          = (RotationCurveInterpolation.Mode)interpolationMode;
     AnimationWindowCurve[]          array         = this.state.activeCurves.ToArray();
     EditorCurveBinding[]            curveBindings = new EditorCurveBinding[array.Length];
     for (int index = 0; index < array.Length; ++index)
     {
         curveBindings[index] = array[index].binding;
     }
     RotationCurveInterpolation.SetInterpolation(this.state.activeAnimationClip, curveBindings, mode);
     this.MaintainTreeviewStateAfterRotationInterpolation(mode);
     this.state.hierarchyData.ReloadData();
 }
Exemple #15
0
 private void ChangeRotationInterpolation(object interpolationMode)
 {
     RotationCurveInterpolation.Mode mode   = (RotationCurveInterpolation.Mode)((int)interpolationMode);
     AnimationWindowCurve[]          array  = this.state.activeCurves.ToArray();
     EditorCurveBinding[]            array2 = new EditorCurveBinding[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         array2[i] = array[i].binding;
     }
     RotationCurveInterpolation.SetInterpolation(this.state.activeAnimationClip, array2, mode);
     this.MaintainTreeviewStateAfterRotationInterpolation(mode);
     this.state.hierarchyData.ReloadData();
 }
        public static UndoPropertyModification[] ProcessModifications(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;
            Animator      component            = activeRootGameObject.GetComponent <Animator>();

            UndoPropertyModification[] result = AnimationRecording.FilterModifications(state, ref modifications);
            int i = 0;

            while (i < modifications.Length)
            {
                EditorCurveBinding   binding       = default(EditorCurveBinding);
                PropertyModification previousValue = modifications[i].previousValue;
                Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                if (type != null)
                {
                    if (component != null && component.isHuman && binding.type == typeof(Transform) && component.gameObject.transform != previousValue.target && component.IsBoneTransform(previousValue.target as Transform))
                    {
                        Debug.LogWarning("Keyframing for humanoid rig is not supported!", previousValue.target as Transform);
                    }
                    else
                    {
                        EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (array != null)
                        {
                            for (int j = 0; j < array.Length; j++)
                            {
                                PropertyModification propertyModification = AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, array[j]);
                                if (propertyModification == null)
                                {
                                    propertyModification = AnimationRecording.CreateDummyPropertyModification(activeRootGameObject, previousValue, array[j]);
                                }
                                state.AddPropertyModification(array[j], propertyModification, modifications[i].keepPrefabOverride);
                                AnimationRecording.AddKey(state, array[j], type, propertyModification);
                            }
                        }
                        else
                        {
                            state.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                            AnimationRecording.AddKey(state, binding, type, previousValue);
                        }
                    }
                }
IL_19A:
                i++;
                continue;
                goto IL_19A;
            }
            return(result);
        }
        private void ChangeRotationInterpolation(System.Object interpolationMode)
        {
            RotationCurveInterpolation.Mode mode = (RotationCurveInterpolation.Mode)interpolationMode;

            AnimationWindowCurve[] activeCurves  = state.activeCurves.ToArray();
            EditorCurveBinding[]   curveBindings = new EditorCurveBinding[activeCurves.Length];

            for (int i = 0; i < activeCurves.Length; i++)
            {
                curveBindings[i] = activeCurves[i].binding;
            }

            RotationCurveInterpolation.SetInterpolation(state.activeAnimationClip, curveBindings, mode);
            MaintainTreeviewStateAfterRotationInterpolation(mode);
            state.hierarchyData.ReloadData();
        }
        public static UndoPropertyModification[] Process(AnimationWindowState state, UndoPropertyModification[] modifications)
        {
            GameObject    rootGameObject      = state.m_RootGameObject;
            AnimationClip activeAnimationClip = state.m_ActiveAnimationClip;
            Animator      component           = rootGameObject.GetComponent <Animator>();

            if (!AnimationRecording.HasAnyRecordableModifications(rootGameObject, modifications))
            {
                return(modifications);
            }
            List <UndoPropertyModification> list = new List <UndoPropertyModification>();

            for (int i = 0; i < modifications.Length; i++)
            {
                EditorCurveBinding   binding = default(EditorCurveBinding);
                PropertyModification propertyModification = modifications[i].propertyModification;
                Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(propertyModification, rootGameObject, out binding);
                if (type != null)
                {
                    if (component != null && component.isHuman && binding.type == typeof(Transform) && component.IsBoneTransform(propertyModification.target as Transform))
                    {
                        Debug.LogWarning("Keyframing for humanoid rig is not supported!", propertyModification.target as Transform);
                    }
                    else
                    {
                        AnimationMode.AddPropertyModification(binding, propertyModification, modifications[i].keepPrefabOverride);
                        EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                        if (array != null)
                        {
                            for (int j = 0; j < array.Length; j++)
                            {
                                AnimationRecording.AddKey(state, array[j], type, AnimationRecording.FindPropertyModification(rootGameObject, modifications, array[j]));
                            }
                        }
                        else
                        {
                            AnimationRecording.AddKey(state, binding, type, propertyModification);
                        }
                    }
                }
                else
                {
                    list.Add(modifications[i]);
                }
            }
            return(list.ToArray());
        }
        // Changing rotation interpolation will change the propertynames of the curves
        // Propertynames are used in treeview node IDs, so we need to anticipate the new IDs by injecting them into treeview state
        // This way treeview state (selection and expanding) will be preserved once the curve data is eventually reloaded
        private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
        {
            List <int> selectedInstaceIDs = state.hierarchyState.selectedIDs;
            List <int> expandedInstaceIDs = state.hierarchyState.expandedIDs;

            List <int> oldIDs = new List <int>();
            List <int> newIds = new List <int>();

            for (int i = 0; i < selectedInstaceIDs.Count; i++)
            {
                AnimationWindowHierarchyNode node = state.hierarchyData.FindItem(selectedInstaceIDs[i]) as AnimationWindowHierarchyNode;

                if (node != null && !node.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
                {
                    string oldPrefix       = node.propertyName.Split('.')[0];
                    string newPropertyName = node.propertyName.Replace(oldPrefix, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));

                    // old treeview node id
                    oldIDs.Add(selectedInstaceIDs[i]);
                    // and its new replacement
                    newIds.Add((node.path + node.animatableObjectType.Name + newPropertyName).GetHashCode());
                }
            }

            // Replace old IDs with new ones
            for (int i = 0; i < oldIDs.Count; i++)
            {
                if (selectedInstaceIDs.Contains(oldIDs[i]))
                {
                    int index = selectedInstaceIDs.IndexOf(oldIDs[i]);
                    selectedInstaceIDs[index] = newIds[i];
                }
                if (expandedInstaceIDs.Contains(oldIDs[i]))
                {
                    int index = expandedInstaceIDs.IndexOf(oldIDs[i]);
                    expandedInstaceIDs[index] = newIds[i];
                }
                if (state.hierarchyState.lastClickedID == oldIDs[i])
                {
                    state.hierarchyState.lastClickedID = newIds[i];
                }
            }

            state.hierarchyState.selectedIDs = new List <int>(selectedInstaceIDs);
            state.hierarchyState.expandedIDs = new List <int>(expandedInstaceIDs);
        }
Exemple #20
0
 private RotationCurveInterpolation.Mode GetRotationInterpolationMode(EditorCurveBinding[] curves)
 {
     if (curves == null || curves.Length == 0)
     {
         return(RotationCurveInterpolation.Mode.Undefined);
     }
     RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(curves[0]);
     for (int i = 1; i < curves.Length; i++)
     {
         RotationCurveInterpolation.Mode modeFromCurveData2 = RotationCurveInterpolation.GetModeFromCurveData(curves[i]);
         if (modeFromCurveData != modeFromCurveData2)
         {
             return(RotationCurveInterpolation.Mode.Undefined);
         }
     }
     return(modeFromCurveData);
 }
Exemple #21
0
        private static void AddRotationKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles)
        {
            AnimationClip activeAnimationClip = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None)
            {
                return;
            }
            EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip);
            for (int index = 0; index < 3; ++index)
            {
                AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, editorCurveBindingArray[index], type);
                if (curve.length == 0 && state.frame != 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(curve, (object)previousEulerAngles[index], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
                AnimationWindowUtility.AddKeyframeToCurve(curve, (object)currentEulerAngles[index], type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
                state.SaveCurve(curve);
            }
        }
Exemple #22
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);
         }
     }
 }
        private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
        {
            List <int> selectedIDs = this.state.hierarchyState.selectedIDs;
            List <int> expandedIDs = this.state.hierarchyState.expandedIDs;
            List <int> list3       = new List <int>();
            List <int> list4       = new List <int>();

            for (int i = 0; i < selectedIDs.Count; i++)
            {
                AnimationWindowHierarchyNode node = this.state.hierarchyData.FindItem(selectedIDs[i]) as AnimationWindowHierarchyNode;
                if ((node != null) && !node.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
                {
                    char[] separator = new char[] { '.' };
                    string oldValue  = node.propertyName.Split(separator)[0];
                    string str2      = node.propertyName.Replace(oldValue, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));
                    list3.Add(selectedIDs[i]);
                    list4.Add((node.path + node.animatableObjectType.Name + str2).GetHashCode());
                }
            }
            for (int j = 0; j < list3.Count; j++)
            {
                if (selectedIDs.Contains(list3[j]))
                {
                    int index = selectedIDs.IndexOf(list3[j]);
                    selectedIDs[index] = list4[j];
                }
                if (expandedIDs.Contains(list3[j]))
                {
                    int num4 = expandedIDs.IndexOf(list3[j]);
                    expandedIDs[num4] = list4[j];
                }
                if (this.state.hierarchyState.lastClickedID == list3[j])
                {
                    this.state.hierarchyState.lastClickedID = list4[j];
                }
            }
            this.state.hierarchyState.selectedIDs = new List <int>(selectedIDs);
            this.state.hierarchyState.expandedIDs = new List <int>(expandedIDs);
        }
 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 #25
0
        public static UndoPropertyModification[] Process(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            GameObject activeRootGameObject = state.activeRootGameObject;

            UndoPropertyModification[] result;
            if (activeRootGameObject == null)
            {
                result = modifications;
            }
            else
            {
                AnimationClip activeAnimationClip = state.activeAnimationClip;
                Animator      component           = activeRootGameObject.GetComponent <Animator>();
                if (!AnimationRecording.HasAnyRecordableModifications(activeRootGameObject, modifications))
                {
                    result = modifications;
                }
                else
                {
                    AnimationRecording.ProcessRotationModifications(state, ref modifications);
                    List <UndoPropertyModification> list = new List <UndoPropertyModification>();
                    int i = 0;
                    while (i < modifications.Length)
                    {
                        EditorCurveBinding   binding       = default(EditorCurveBinding);
                        PropertyModification previousValue = modifications[i].previousValue;
                        Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, activeRootGameObject, out binding);
                        if (type != null)
                        {
                            if (component != null && component.isHuman && binding.type == typeof(Transform) && component.IsBoneTransform(previousValue.target as Transform))
                            {
                                Debug.LogWarning("Keyframing for humanoid rig is not supported!", previousValue.target as Transform);
                            }
                            else
                            {
                                AnimationMode.AddPropertyModification(binding, previousValue, modifications[i].keepPrefabOverride);
                                EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForAddKey(binding, activeAnimationClip);
                                if (array != null)
                                {
                                    for (int j = 0; j < array.Length; j++)
                                    {
                                        AnimationRecording.AddKey(state, array[j], type, AnimationRecording.FindPropertyModification(activeRootGameObject, modifications, array[j]));
                                    }
                                }
                                else
                                {
                                    AnimationRecording.AddKey(state, binding, type, previousValue);
                                }
                            }
                        }
                        else
                        {
                            list.Add(modifications[i]);
                        }
IL_17C:
                        i++;
                        continue;
                        goto IL_17C;
                    }
                    result = list.ToArray();
                }
            }
            return(result);
        }
Exemple #26
0
        private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
        {
            List <int> selectedIds = this.state.hierarchyState.selectedIDs;
            List <int> expandedIds = this.state.hierarchyState.expandedIDs;
            List <int> intList1    = new List <int>();
            List <int> intList2    = new List <int>();

            for (int index = 0; index < selectedIds.Count; ++index)
            {
                AnimationWindowHierarchyNode windowHierarchyNode = this.state.hierarchyData.FindItem(selectedIds[index]) as AnimationWindowHierarchyNode;
                if (windowHierarchyNode != null && !windowHierarchyNode.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
                {
                    string oldValue = windowHierarchyNode.propertyName.Split('.')[0];
                    string str      = windowHierarchyNode.propertyName.Replace(oldValue, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));
                    intList1.Add(selectedIds[index]);
                    intList2.Add((windowHierarchyNode.path + windowHierarchyNode.animatableObjectType.Name + str).GetHashCode());
                }
            }
            for (int index1 = 0; index1 < intList1.Count; ++index1)
            {
                if (selectedIds.Contains(intList1[index1]))
                {
                    int index2 = selectedIds.IndexOf(intList1[index1]);
                    selectedIds[index2] = intList2[index1];
                }
                if (expandedIds.Contains(intList1[index1]))
                {
                    int index2 = expandedIds.IndexOf(intList1[index1]);
                    expandedIds[index2] = intList2[index1];
                }
                if (this.state.hierarchyState.lastClickedID == intList1[index1])
                {
                    this.state.hierarchyState.lastClickedID = intList2[index1];
                }
            }
            this.state.hierarchyState.selectedIDs = new List <int>((IEnumerable <int>)selectedIds);
            this.state.hierarchyState.expandedIDs = new List <int>((IEnumerable <int>)expandedIds);
        }
        private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
        {
            List <int> selectedIDs = this.state.m_hierarchyState.selectedIDs;
            List <int> expandedIDs = this.state.m_hierarchyState.expandedIDs;
            List <int> list        = new List <int>();
            List <int> list2       = new List <int>();

            for (int i = 0; i < selectedIDs.Count; i++)
            {
                AnimationWindowHierarchyNode animationWindowHierarchyNode = this.state.m_HierarchyData.FindItem(selectedIDs[i]) as AnimationWindowHierarchyNode;
                if (animationWindowHierarchyNode != null && !animationWindowHierarchyNode.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
                {
                    string oldValue = animationWindowHierarchyNode.propertyName.Split(new char[]
                    {
                        '.'
                    })[0];
                    string str = animationWindowHierarchyNode.propertyName.Replace(oldValue, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));
                    list.Add(selectedIDs[i]);
                    list2.Add((animationWindowHierarchyNode.path + animationWindowHierarchyNode.animatableObjectType.Name + str).GetHashCode());
                }
            }
            for (int j = 0; j < list.Count; j++)
            {
                if (selectedIDs.Contains(list[j]))
                {
                    int index = selectedIDs.IndexOf(list[j]);
                    selectedIDs[index] = list2[j];
                }
                if (expandedIDs.Contains(list[j]))
                {
                    int index2 = expandedIDs.IndexOf(list[j]);
                    expandedIDs[index2] = list2[j];
                }
                if (this.state.m_hierarchyState.lastClickedID == list[j])
                {
                    this.state.m_hierarchyState.lastClickedID = list2[j];
                }
            }
            this.state.m_hierarchyState.selectedIDs = new List <int>(selectedIDs);
            this.state.m_hierarchyState.expandedIDs = new List <int>(expandedIDs);
        }
Exemple #28
0
 public static RotationMode GetRotationMode(EditorCurveBinding binding)
 {
     return((RotationMode)RotationCurveInterpolation.GetModeFromCurveData(binding));
 }
Exemple #29
0
 public static string CreateRawQuaternionsBindingName(string componentName)
 {
     return($"{RotationCurveInterpolation.GetPrefixForInterpolation(RotationCurveInterpolation.Mode.RawQuaternions)}.{componentName}");
 }