GetPrefixForInterpolation() public static method

public static GetPrefixForInterpolation ( Mode newInterpolationMode ) : string
newInterpolationMode Mode
return string
 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)]);
            }
        }
Exemplo n.º 4
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)]);
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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)]);
                }
            }
        }