Пример #1
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());
        }
Пример #2
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());
        }
Пример #3
0
        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);
        }
Пример #4
0
        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());
        }
Пример #5
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);
        }