GetModeFromCurveData() public static méthode

public static GetModeFromCurveData ( EditorCurveBinding data ) : Mode
data EditorCurveBinding
Résultat Mode
 public static void UpdateTangentsFromMode(AnimationCurve curve, AnimationClip clip, EditorCurveBinding curveBinding)
 {
     if (RotationCurveInterpolation.GetModeFromCurveData(curveBinding) == RotationCurveInterpolation.Mode.NonBaked)
     {
         QuaternionCurveTangentCalculation quaternionCurveTangentCalculation = default(QuaternionCurveTangentCalculation);
         int curveIndexFromName = RotationCurveInterpolation.GetCurveIndexFromName(curveBinding.propertyName);
         for (int i = 0; i < 3; i++)
         {
             if (i == curveIndexFromName)
             {
                 quaternionCurveTangentCalculation.SetCurve(i, curve);
             }
             else
             {
                 EditorCurveBinding binding = curveBinding;
                 binding.propertyName = "localEulerAngles." + RotationCurveInterpolation.kPostFix[i];
                 AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(clip, binding);
                 if (editorCurve == null)
                 {
                     return;
                 }
                 quaternionCurveTangentCalculation.SetCurve(i, editorCurve);
             }
         }
         quaternionCurveTangentCalculation.UpdateTangentsFromMode(curveIndexFromName);
     }
     else
     {
         CurveUtility.UpdateTangentsFromMode(curve);
     }
 }
Exemple #2
0
 public static RotationCurveInterpolation.State GetCurveState(AnimationClip clip, EditorCurveBinding[] selection)
 {
     RotationCurveInterpolation.State result;
     result.allAreNonBaked  = true;
     result.allAreBaked     = false;
     result.allAreRotations = false;
     for (int i = 0; i < selection.Length; i++)
     {
         EditorCurveBinding data = selection[i];
         RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(data);
         if (modeFromCurveData == RotationCurveInterpolation.Mode.NonBaked)
         {
             result.allAreNonBaked = false;
         }
         else
         {
             if (modeFromCurveData == RotationCurveInterpolation.Mode.Baked)
             {
                 result.allAreBaked = false;
             }
             else
             {
                 result.allAreRotations = false;
             }
         }
     }
     return(result);
 }
 internal static EditorCurveBinding[] ConvertRotationPropertiesToInterpolationType(EditorCurveBinding[] selection, RotationCurveInterpolation.Mode newInterpolationMode)
 {
     EditorCurveBinding[] result;
     if (selection.Length != 4)
     {
         result = selection;
     }
     else if (RotationCurveInterpolation.GetModeFromCurveData(selection[0]) == RotationCurveInterpolation.Mode.RawQuaternions)
     {
         EditorCurveBinding[] array = new EditorCurveBinding[]
         {
             selection[0],
             selection[1],
             selection[2]
         };
         string prefixForInterpolation = RotationCurveInterpolation.GetPrefixForInterpolation(newInterpolationMode);
         array[0].propertyName = prefixForInterpolation + ".x";
         array[1].propertyName = prefixForInterpolation + ".y";
         array[2].propertyName = prefixForInterpolation + ".z";
         result = array;
     }
     else
     {
         result = selection;
     }
     return(result);
 }
        public static EditorCurveBinding RemapAnimationBindingForRotationCurves(EditorCurveBinding curveBinding, AnimationClip clip)
        {
            EditorCurveBinding result;

            if (!AnimationWindowUtility.IsTransformType(curveBinding.type))
            {
                result = curveBinding;
            }
            else
            {
                RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(curveBinding);
                if (modeFromCurveData != RotationCurveInterpolation.Mode.Undefined)
                {
                    string str = curveBinding.propertyName.Split(new char[]
                    {
                        '.'
                    })[1];
                    EditorCurveBinding editorCurveBinding = curveBinding;
                    if (modeFromCurveData != RotationCurveInterpolation.Mode.NonBaked)
                    {
                        editorCurveBinding.propertyName = RotationCurveInterpolation.GetPrefixForInterpolation(RotationCurveInterpolation.Mode.NonBaked) + "." + str;
                        AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(clip, editorCurveBinding);
                        if (editorCurve != null)
                        {
                            result = editorCurveBinding;
                            return(result);
                        }
                    }
                    if (modeFromCurveData != RotationCurveInterpolation.Mode.Baked)
                    {
                        editorCurveBinding.propertyName = RotationCurveInterpolation.GetPrefixForInterpolation(RotationCurveInterpolation.Mode.Baked) + "." + str;
                        AnimationCurve editorCurve2 = AnimationUtility.GetEditorCurve(clip, editorCurveBinding);
                        if (editorCurve2 != null)
                        {
                            result = editorCurveBinding;
                            return(result);
                        }
                    }
                    if (modeFromCurveData != RotationCurveInterpolation.Mode.RawEuler)
                    {
                        editorCurveBinding.propertyName = RotationCurveInterpolation.GetPrefixForInterpolation(RotationCurveInterpolation.Mode.RawEuler) + "." + str;
                        AnimationCurve editorCurve3 = AnimationUtility.GetEditorCurve(clip, editorCurveBinding);
                        if (editorCurve3 != null)
                        {
                            result = editorCurveBinding;
                            return(result);
                        }
                    }
                    result = curveBinding;
                }
                else
                {
                    result = curveBinding;
                }
            }
            return(result);
        }
        internal static void SetInterpolation(AnimationClip clip, EditorCurveBinding[] curveBindings, RotationCurveInterpolation.Mode newInterpolationMode)
        {
            Undo.RegisterCompleteObjectUndo(clip, "Rotation Interpolation");
            if (clip.legacy && newInterpolationMode == RotationCurveInterpolation.Mode.RawEuler)
            {
                Debug.LogWarning("Warning, Euler Angles interpolation mode is not fully supported for Legacy animation clips. If you mix clips using Euler Angles interpolation with clips using other interpolation modes (using Animation.CrossFade, Animation.Blend or other methods), you will get erroneous results. Use with caution.", clip);
            }
            List <EditorCurveBinding> list  = new List <EditorCurveBinding>();
            List <AnimationCurve>     list2 = new List <AnimationCurve>();
            List <EditorCurveBinding> list3 = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding editorCurveBinding             = curveBindings[i];
                RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(editorCurveBinding);
                if (modeFromCurveData != RotationCurveInterpolation.Mode.Undefined)
                {
                    if (modeFromCurveData == RotationCurveInterpolation.Mode.RawQuaternions)
                    {
                        Debug.LogWarning("Can't convert quaternion curve: " + editorCurveBinding.propertyName);
                    }
                    else
                    {
                        AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(clip, editorCurveBinding);
                        if (editorCurve != null)
                        {
                            string propertyName = RotationCurveInterpolation.GetPrefixForInterpolation(newInterpolationMode) + '.' + RotationCurveInterpolation.ExtractComponentCharacter(editorCurveBinding.propertyName);
                            list.Add(new EditorCurveBinding
                            {
                                propertyName = propertyName,
                                type         = editorCurveBinding.type,
                                path         = editorCurveBinding.path
                            });
                            list2.Add(editorCurve);
                            list3.Add(new EditorCurveBinding
                            {
                                propertyName = editorCurveBinding.propertyName,
                                type         = editorCurveBinding.type,
                                path         = editorCurveBinding.path
                            });
                        }
                    }
                }
            }
            Undo.RegisterCompleteObjectUndo(clip, "Rotation Interpolation");
            foreach (EditorCurveBinding current in list3)
            {
                AnimationUtility.SetEditorCurve(clip, current, null);
            }
            foreach (EditorCurveBinding current2 in list)
            {
                AnimationUtility.SetEditorCurve(clip, current2, list2[list.IndexOf(current2)]);
            }
        }
Exemple #6
0
        internal static void SetInterpolation(AnimationClip clip, EditorCurveBinding[] curveBindings, RotationCurveInterpolation.Mode newInterpolationMode)
        {
            Undo.RegisterCompleteObjectUndo(clip, "Rotation Interpolation");
            List <EditorCurveBinding> list  = new List <EditorCurveBinding>();
            List <AnimationCurve>     list2 = new List <AnimationCurve>();
            List <EditorCurveBinding> list3 = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding editorCurveBinding             = curveBindings[i];
                RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(editorCurveBinding);
                if (modeFromCurveData != RotationCurveInterpolation.Mode.Undefined)
                {
                    if (modeFromCurveData == RotationCurveInterpolation.Mode.RawQuaternions)
                    {
                        Debug.LogWarning("Can't convert quaternion curve: " + editorCurveBinding.propertyName);
                    }
                    else
                    {
                        AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(clip, editorCurveBinding);
                        if (editorCurve != null)
                        {
                            string propertyName = RotationCurveInterpolation.GetPrefixForInterpolation(newInterpolationMode) + '.' + RotationCurveInterpolation.ExtractComponentCharacter(editorCurveBinding.propertyName);
                            list.Add(new EditorCurveBinding
                            {
                                propertyName = propertyName,
                                type         = editorCurveBinding.type,
                                path         = editorCurveBinding.path
                            });
                            list2.Add(editorCurve);
                            list3.Add(new EditorCurveBinding
                            {
                                propertyName = editorCurveBinding.propertyName,
                                type         = editorCurveBinding.type,
                                path         = editorCurveBinding.path
                            });
                        }
                    }
                }
            }
            Undo.RegisterCompleteObjectUndo(clip, "Rotation Interpolation");
            foreach (EditorCurveBinding current in list3)
            {
                AnimationUtility.SetEditorCurve(clip, current, null);
            }
            foreach (EditorCurveBinding current2 in list)
            {
                AnimationUtility.SetEditorCurve(clip, current2, list2[list.IndexOf(current2)]);
            }
        }
Exemple #7
0
 public static RotationCurveInterpolation.State GetCurveState(AnimationClip clip, EditorCurveBinding[] selection)
 {
     RotationCurveInterpolation.State state;
     state.allAreRaw       = true;
     state.allAreNonBaked  = true;
     state.allAreBaked     = true;
     state.allAreRotations = true;
     foreach (EditorCurveBinding data in selection)
     {
         RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(data);
         state.allAreBaked     &= modeFromCurveData == RotationCurveInterpolation.Mode.Baked;
         state.allAreNonBaked  &= modeFromCurveData == RotationCurveInterpolation.Mode.NonBaked;
         state.allAreRaw       &= modeFromCurveData == RotationCurveInterpolation.Mode.RawEuler;
         state.allAreRotations &= modeFromCurveData != RotationCurveInterpolation.Mode.Undefined;
     }
     return(state);
 }
 public static RotationCurveInterpolation.State GetCurveState(AnimationClip clip, EditorCurveBinding[] selection)
 {
     RotationCurveInterpolation.State result;
     result.allAreRaw       = true;
     result.allAreNonBaked  = true;
     result.allAreBaked     = true;
     result.allAreRotations = true;
     for (int i = 0; i < selection.Length; i++)
     {
         EditorCurveBinding data = selection[i];
         RotationCurveInterpolation.Mode modeFromCurveData = RotationCurveInterpolation.GetModeFromCurveData(data);
         result.allAreBaked     &= (modeFromCurveData == RotationCurveInterpolation.Mode.Baked);
         result.allAreNonBaked  &= (modeFromCurveData == RotationCurveInterpolation.Mode.NonBaked);
         result.allAreRaw       &= (modeFromCurveData == RotationCurveInterpolation.Mode.RawEuler);
         result.allAreRotations &= (modeFromCurveData != RotationCurveInterpolation.Mode.Undefined);
     }
     return(result);
 }
Exemple #9
0
        internal static EditorCurveBinding[] ConvertRotationPropertiesToInterpolationType(EditorCurveBinding[] selection, RotationCurveInterpolation.Mode newInterpolationMode)
        {
            if (selection.Length != 4 || RotationCurveInterpolation.GetModeFromCurveData(selection[0]) != RotationCurveInterpolation.Mode.RawQuaternions)
            {
                return(selection);
            }
            EditorCurveBinding[] editorCurveBindingArray = new EditorCurveBinding[3]
            {
                selection[0],
                selection[1],
                selection[2]
            };
            string forInterpolation = RotationCurveInterpolation.GetPrefixForInterpolation(newInterpolationMode);

            editorCurveBindingArray[0].propertyName = forInterpolation + ".x";
            editorCurveBindingArray[1].propertyName = forInterpolation + ".y";
            editorCurveBindingArray[2].propertyName = forInterpolation + ".z";
            return(editorCurveBindingArray);
        }
Exemple #10
0
        internal static void SetInterpolation(AnimationClip clip, EditorCurveBinding[] curveBindings, RotationCurveInterpolation.Mode newInterpolationMode)
        {
            Undo.RegisterCompleteObjectUndo((UnityEngine.Object)clip, "Rotation Interpolation");
            if (clip.legacy && newInterpolationMode == RotationCurveInterpolation.Mode.RawEuler)
            {
                Debug.LogWarning((object)"Warning, Euler Angles interpolation mode is not fully supported for Legacy animation clips. If you mix clips using Euler Angles interpolation with clips using other interpolation modes (using Animation.CrossFade, Animation.Blend or other methods), you will get erroneous results. Use with caution.", (UnityEngine.Object)clip);
            }
            List <EditorCurveBinding> editorCurveBindingList1 = new List <EditorCurveBinding>();
            List <AnimationCurve>     animationCurveList      = new List <AnimationCurve>();
            List <EditorCurveBinding> editorCurveBindingList2 = new List <EditorCurveBinding>();

            foreach (EditorCurveBinding curveBinding in curveBindings)
            {
                switch (RotationCurveInterpolation.GetModeFromCurveData(curveBinding))
                {
                case RotationCurveInterpolation.Mode.Undefined:
                    continue;

                case RotationCurveInterpolation.Mode.RawQuaternions:
                    Debug.LogWarning((object)("Can't convert quaternion curve: " + curveBinding.propertyName));
                    continue;

                default:
                    AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(clip, curveBinding);
                    if (editorCurve != null)
                    {
                        string str = RotationCurveInterpolation.GetPrefixForInterpolation(newInterpolationMode) + (object)'.' + (object)RotationCurveInterpolation.ExtractComponentCharacter(curveBinding.propertyName);
                        editorCurveBindingList1.Add(new EditorCurveBinding()
                        {
                            propertyName = str,
                            type         = curveBinding.type,
                            path         = curveBinding.path
                        });
                        animationCurveList.Add(editorCurve);
                        editorCurveBindingList2.Add(new EditorCurveBinding()
                        {
                            propertyName = curveBinding.propertyName,
                            type         = curveBinding.type,
                            path         = curveBinding.path
                        });
                        continue;
                    }
                    continue;
                }
            }
            Undo.RegisterCompleteObjectUndo((UnityEngine.Object)clip, "Rotation Interpolation");
            using (List <EditorCurveBinding> .Enumerator enumerator = editorCurveBindingList2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    EditorCurveBinding current = enumerator.Current;
                    AnimationUtility.SetEditorCurve(clip, current, (AnimationCurve)null);
                }
            }
            using (List <EditorCurveBinding> .Enumerator enumerator = editorCurveBindingList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    EditorCurveBinding current = enumerator.Current;
                    AnimationUtility.SetEditorCurve(clip, current, animationCurveList[editorCurveBindingList1.IndexOf(current)]);
                }
            }
        }