AddRotationKey() private static method

private static AddRotationKey ( IAnimationRecordingState state, EditorCurveBinding binding, Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles ) : void
state IAnimationRecordingState
binding UnityEditor.EditorCurveBinding
type Type
previousEulerAngles UnityEngine.Vector3
currentEulerAngles UnityEngine.Vector3
return void
Beispiel #1
0
        private static void ProcessRotationModifications(IAnimationRecordingState state, ref Dictionary <object, AnimationRecording.RotationModification> rotationModifications)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current in rotationModifications)
            {
                AnimationRecording.RotationModification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(value.lastQuatModification.currentValue, state.activeRootGameObject, out editorCurveBinding);
                    if (type != null)
                    {
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.x);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.y);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.z);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.w);
                        Quaternion localRotation  = transform.localRotation;
                        Quaternion localRotation2 = transform.localRotation;
                        object     obj;
                        if (AnimationRecording.ValueFromPropertyModification(value.x.previousValue, editorCurveBinding, out obj))
                        {
                            localRotation.x = (float)obj;
                        }
                        object obj2;
                        if (AnimationRecording.ValueFromPropertyModification(value.y.previousValue, editorCurveBinding, out obj2))
                        {
                            localRotation.y = (float)obj2;
                        }
                        object obj3;
                        if (AnimationRecording.ValueFromPropertyModification(value.z.previousValue, editorCurveBinding, out obj3))
                        {
                            localRotation.z = (float)obj3;
                        }
                        object obj4;
                        if (AnimationRecording.ValueFromPropertyModification(value.w.previousValue, editorCurveBinding, out obj4))
                        {
                            localRotation.w = (float)obj4;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.x.currentValue, editorCurveBinding, out obj))
                        {
                            localRotation2.x = (float)obj;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.y.currentValue, editorCurveBinding, out obj2))
                        {
                            localRotation2.y = (float)obj2;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.z.currentValue, editorCurveBinding, out obj3))
                        {
                            localRotation2.z = (float)obj3;
                        }
                        if (AnimationRecording.ValueFromPropertyModification(value.w.currentValue, editorCurveBinding, out obj4))
                        {
                            localRotation2.w = (float)obj4;
                        }
                        if (value.useEuler)
                        {
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerX);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerY);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerZ);
                            Vector3 vector  = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            Vector3 vector2 = vector;
                            object  obj5;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.previousValue, editorCurveBinding, out obj5))
                            {
                                vector.x = (float)obj5;
                            }
                            object obj6;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.previousValue, editorCurveBinding, out obj6))
                            {
                                vector.y = (float)obj6;
                            }
                            object obj7;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.previousValue, editorCurveBinding, out obj7))
                            {
                                vector.z = (float)obj7;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.currentValue, editorCurveBinding, out obj5))
                            {
                                vector2.x = (float)obj5;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.currentValue, editorCurveBinding, out obj6))
                            {
                                vector2.y = (float)obj6;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.currentValue, editorCurveBinding, out obj7))
                            {
                                vector2.z = (float)obj7;
                            }
                            vector  = AnimationUtility.GetClosestEuler(localRotation, vector, RotationOrder.OrderZXY);
                            vector2 = AnimationUtility.GetClosestEuler(localRotation2, vector2, RotationOrder.OrderZXY);
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, vector, vector2);
                        }
                        else
                        {
                            Vector3 localEulerAngles = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            Vector3 closestEuler     = AnimationUtility.GetClosestEuler(localRotation, localEulerAngles, RotationOrder.OrderZXY);
                            Vector3 closestEuler2    = AnimationUtility.GetClosestEuler(localRotation2, localEulerAngles, RotationOrder.OrderZXY);
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, closestEuler, closestEuler2);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private static void ProcessRotationModifications(IAnimationRecordingState state, ref UndoPropertyModification[] modifications)
        {
            Dictionary <object, AnimationRecording.RotationModification> dictionary = new Dictionary <object, AnimationRecording.RotationModification>();

            AnimationRecording.CollectRotationModifications(state, ref modifications, ref dictionary);
            foreach (KeyValuePair <object, AnimationRecording.RotationModification> current in dictionary)
            {
                AnimationRecording.RotationModification value = current.Value;
                Transform transform = current.Key as Transform;
                if (!(transform == null))
                {
                    EditorCurveBinding editorCurveBinding = default(EditorCurveBinding);
                    Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(value.lastQuatModification.currentValue, state.activeRootGameObject, out editorCurveBinding);
                    if (type != null)
                    {
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.x);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.y);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.z);
                        AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.w);
                        if (value.useEuler)
                        {
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerX);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerY);
                            AnimationRecording.AddRotationPropertyModification(state, editorCurveBinding, value.eulerZ);
                            Vector3 localEulerAngles  = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            Vector3 localEulerAngles2 = transform.GetLocalEulerAngles(RotationOrder.OrderZXY);
                            object  obj;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.previousValue, editorCurveBinding, out obj))
                            {
                                localEulerAngles.x = (float)obj;
                            }
                            object obj2;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.previousValue, editorCurveBinding, out obj2))
                            {
                                localEulerAngles.y = (float)obj2;
                            }
                            object obj3;
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.previousValue, editorCurveBinding, out obj3))
                            {
                                localEulerAngles.z = (float)obj3;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerX.currentValue, editorCurveBinding, out obj))
                            {
                                localEulerAngles2.x = (float)obj;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerY.currentValue, editorCurveBinding, out obj2))
                            {
                                localEulerAngles2.y = (float)obj2;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.eulerZ.currentValue, editorCurveBinding, out obj3))
                            {
                                localEulerAngles2.z = (float)obj3;
                            }
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, localEulerAngles, localEulerAngles2);
                        }
                        else
                        {
                            Quaternion localRotation  = transform.localRotation;
                            Quaternion localRotation2 = transform.localRotation;
                            object     obj4;
                            if (AnimationRecording.ValueFromPropertyModification(value.x.previousValue, editorCurveBinding, out obj4))
                            {
                                localRotation.x = (float)obj4;
                            }
                            object obj5;
                            if (AnimationRecording.ValueFromPropertyModification(value.y.previousValue, editorCurveBinding, out obj5))
                            {
                                localRotation.y = (float)obj5;
                            }
                            object obj6;
                            if (AnimationRecording.ValueFromPropertyModification(value.z.previousValue, editorCurveBinding, out obj6))
                            {
                                localRotation.z = (float)obj6;
                            }
                            object obj7;
                            if (AnimationRecording.ValueFromPropertyModification(value.w.previousValue, editorCurveBinding, out obj7))
                            {
                                localRotation.w = (float)obj7;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.x.currentValue, editorCurveBinding, out obj4))
                            {
                                localRotation2.x = (float)obj4;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.y.currentValue, editorCurveBinding, out obj5))
                            {
                                localRotation2.y = (float)obj5;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.z.currentValue, editorCurveBinding, out obj6))
                            {
                                localRotation2.z = (float)obj6;
                            }
                            if (AnimationRecording.ValueFromPropertyModification(value.w.currentValue, editorCurveBinding, out obj7))
                            {
                                localRotation2.w = (float)obj7;
                            }
                            AnimationRecording.AddRotationKey(state, editorCurveBinding, type, localRotation.eulerAngles, localRotation2.eulerAngles);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private static void ProcessRotationModifications(AnimationWindowState state, ref UndoPropertyModification[] modifications)
        {
            Dictionary <object, AnimationRecording.RotationModification> rotationModifications = new Dictionary <object, AnimationRecording.RotationModification>();

            AnimationRecording.CollectRotationModifications(state, ref modifications, ref rotationModifications);
            using (Dictionary <object, AnimationRecording.RotationModification> .Enumerator enumerator = rotationModifications.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    AnimationRecording.RotationModification rotationModification = enumerator.Current.Value;
                    EditorCurveBinding binding            = new EditorCurveBinding();
                    System.Type        editorCurveBinding = AnimationUtility.PropertyModificationToEditorCurveBinding(rotationModification.lastQuatModification.currentValue, state.activeRootGameObject, out binding);
                    Quaternion         localRotation1     = state.activeRootGameObject.transform.localRotation;
                    Quaternion         localRotation2     = state.activeRootGameObject.transform.localRotation;
                    object             outObject1;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.x.previousValue, binding, out outObject1))
                    {
                        localRotation1.x = (float)outObject1;
                    }
                    object outObject2;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.y.previousValue, binding, out outObject2))
                    {
                        localRotation1.y = (float)outObject2;
                    }
                    object outObject3;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.z.previousValue, binding, out outObject3))
                    {
                        localRotation1.z = (float)outObject3;
                    }
                    object outObject4;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.w.previousValue, binding, out outObject4))
                    {
                        localRotation1.w = (float)outObject4;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.x.currentValue, binding, out outObject1))
                    {
                        localRotation2.x = (float)outObject1;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.y.currentValue, binding, out outObject2))
                    {
                        localRotation2.y = (float)outObject2;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.z.currentValue, binding, out outObject3))
                    {
                        localRotation2.z = (float)outObject3;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.w.currentValue, binding, out outObject4))
                    {
                        localRotation2.w = (float)outObject4;
                    }
                    Vector3 eulerAngles1 = localRotation1.eulerAngles;
                    Vector3 eulerAngles2 = localRotation2.eulerAngles;
                    object  outObject5;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerX.previousValue, binding, out outObject5))
                    {
                        eulerAngles1.x = (float)outObject5;
                    }
                    object outObject6;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerY.previousValue, binding, out outObject6))
                    {
                        eulerAngles1.y = (float)outObject6;
                    }
                    object outObject7;
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerZ.previousValue, binding, out outObject7))
                    {
                        eulerAngles1.z = (float)outObject7;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerX.currentValue, binding, out outObject5))
                    {
                        eulerAngles2.x = (float)outObject5;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerY.currentValue, binding, out outObject6))
                    {
                        eulerAngles2.y = (float)outObject6;
                    }
                    if (AnimationRecording.ValueFromPropertyModification(rotationModification.eulerZ.currentValue, binding, out outObject7))
                    {
                        eulerAngles2.z = (float)outObject7;
                    }
                    AnimationRecording.AddRotationKey(state, binding, editorCurveBinding, eulerAngles1, eulerAngles2);
                }
            }
        }