Example #1
0
        private static void CollectVector3Modifications(IAnimationRecordingState state, ref UndoPropertyModification[] modifications, ref Dictionary <object, AnimationRecording.Vector3Modification> vector3Modifications, string propertyName)
        {
            List <UndoPropertyModification> list = new List <UndoPropertyModification>();

            UndoPropertyModification[] array = modifications;
            for (int i = 0; i < array.Length; i++)
            {
                UndoPropertyModification undoPropertyModification = array[i];
                PropertyModification     previousValue            = undoPropertyModification.previousValue;
                if (!(previousValue.target is Transform))
                {
                    list.Add(undoPropertyModification);
                }
                else
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    AnimationUtility.PropertyModificationToEditorCurveBinding(previousValue, state.activeRootGameObject, out editorCurveBinding);
                    if (editorCurveBinding.propertyName.StartsWith(propertyName))
                    {
                        AnimationRecording.Vector3Modification vector3Modification;
                        if (!vector3Modifications.TryGetValue(previousValue.target, out vector3Modification))
                        {
                            vector3Modification = new AnimationRecording.Vector3Modification();
                            vector3Modifications[previousValue.target] = vector3Modification;
                        }
                        if (editorCurveBinding.propertyName.EndsWith("x"))
                        {
                            vector3Modification.x = undoPropertyModification;
                        }
                        else if (editorCurveBinding.propertyName.EndsWith("y"))
                        {
                            vector3Modification.y = undoPropertyModification;
                        }
                        else if (editorCurveBinding.propertyName.EndsWith("z"))
                        {
                            vector3Modification.z = undoPropertyModification;
                        }
                        vector3Modification.last = undoPropertyModification;
                    }
                    else
                    {
                        list.Add(undoPropertyModification);
                    }
                }
            }
            if (vector3Modifications.Count > 0)
            {
                modifications = list.ToArray();
            }
        }
Example #2
0
        public static void ProcessVector3Modifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.Vector3Modification> vector3Modifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            foreach (KeyValuePair <object, AnimationRecording.Vector3Modification> current in vector3Modifications)
            {
                AnimationRecording.Vector3Modification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding baseBinding = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value.last.currentValue, state.activeRootGameObject, out baseBinding) != null)
                    {
                        AnimationRecording.ProcessVector3Modification(state, baseBinding, value.x, transform, "x");
                        AnimationRecording.ProcessVector3Modification(state, baseBinding, value.y, transform, "y");
                        AnimationRecording.ProcessVector3Modification(state, baseBinding, value.z, transform, "z");
                    }
                }
            }
        }
Example #3
0
        private static void ProcessAnimatorModifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.Vector3Modification> positionModifications, ref Dictionary <object, AnimationRecording.RotationModification> rotationModifications, ref Dictionary <object, AnimationRecording.Vector3Modification> scaleModifications)
        {
            Dictionary <object, AnimationRecording.RootMotionModification> dictionary = new Dictionary <object, AnimationRecording.RootMotionModification>();
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;
            Animator      component            = activeRootGameObject.GetComponent <Animator>();
            bool          flag  = component != null && component.isHuman;
            bool          flag2 = component != null && component.hasRootMotion;
            bool          flag3 = component != null && component.applyRootMotion;
            List <object> list  = new List <object>();

            foreach (KeyValuePair <object, AnimationRecording.Vector3Modification> current in positionModifications)
            {
                AnimationRecording.Vector3Modification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value.last.currentValue, state.activeRootGameObject, out editorCurveBinding) != null)
                    {
                        bool flag4 = activeRootGameObject.transform == transform;
                        bool flag5 = (flag || flag2 || flag3) && flag4;
                        bool flag6 = flag && !flag4 && component.IsBoneTransform(transform);
                        if (flag6)
                        {
                            Debug.LogWarning("Keyframing translation on humanoid rig is not supported!", transform);
                            list.Add(current.Key);
                        }
                        else if (flag5)
                        {
                            AnimationRecording.RootMotionModification rootMotionModification;
                            if (!dictionary.TryGetValue(transform, out rootMotionModification))
                            {
                                rootMotionModification = new AnimationRecording.RootMotionModification();
                                dictionary[transform]  = rootMotionModification;
                            }
                            rootMotionModification.lastP = value.last;
                            rootMotionModification.px    = value.x;
                            rootMotionModification.py    = value.y;
                            rootMotionModification.pz    = value.z;
                            list.Add(current.Key);
                        }
                    }
                }
            }
            foreach (object current2 in list)
            {
                positionModifications.Remove(current2);
            }
            List <object> list2 = new List <object>();

            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current3 in rotationModifications)
            {
                AnimationRecording.RotationModification value2 = current3.Value;
                Transform transform2 = current3.Key as Transform;
                if (!(transform2 == null))
                {
                    EditorCurveBinding editorCurveBinding2 = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value2.lastQuatModification.currentValue, state.activeRootGameObject, out editorCurveBinding2) != null)
                    {
                        bool flag7 = activeRootGameObject.transform == transform2;
                        bool flag8 = (flag || flag2 || flag3) && flag7;
                        bool flag9 = flag && !flag7 && component.IsBoneTransform(transform2);
                        if (flag9)
                        {
                            Debug.LogWarning("Keyframing rotation on humanoid rig is not supported!", transform2);
                            list2.Add(current3.Key);
                        }
                        else if (flag8)
                        {
                            AnimationRecording.RootMotionModification rootMotionModification2;
                            if (!dictionary.TryGetValue(transform2, out rootMotionModification2))
                            {
                                rootMotionModification2 = new AnimationRecording.RootMotionModification();
                                dictionary[transform2]  = rootMotionModification2;
                            }
                            rootMotionModification2.lastR = value2.lastQuatModification;
                            rootMotionModification2.rx    = value2.x;
                            rootMotionModification2.ry    = value2.y;
                            rootMotionModification2.rz    = value2.z;
                            rootMotionModification2.rw    = value2.w;
                            list2.Add(current3.Key);
                        }
                    }
                }
            }
            foreach (object current4 in list2)
            {
                rotationModifications.Remove(current4);
            }
            List <object> list3 = new List <object>();

            foreach (KeyValuePair <object, AnimationRecording.Vector3Modification> current5 in scaleModifications)
            {
                AnimationRecording.Vector3Modification value3 = current5.Value;
                Transform transform3 = current5.Key as Transform;
                if (!(transform3 == null))
                {
                    EditorCurveBinding editorCurveBinding3 = default(EditorCurveBinding);
                    if (AnimationUtility.PropertyModificationToEditorCurveBinding(value3.last.currentValue, state.activeRootGameObject, out editorCurveBinding3) != null)
                    {
                        bool flag10 = activeRootGameObject.transform == transform3;
                        bool flag11 = flag && !flag10 && component.IsBoneTransform(transform3);
                        if (flag11)
                        {
                            Debug.LogWarning("Keyframing scale on humanoid rig is not supported!", transform3);
                            list3.Add(current5.Key);
                        }
                    }
                }
            }
            foreach (object current6 in list3)
            {
                scaleModifications.Remove(current6);
            }
            AnimationRecording.ProcessRootMotionModifications(state, ref dictionary);
        }