コード例 #1
0
 public static EditorCurveBinding[] RemapAnimationBindingForAddKey(EditorCurveBinding binding, AnimationClip clip)
 {
     if (!AnimationWindowUtility.IsTransformType(binding.type))
     {
         return(null);
     }
     if (binding.propertyName.StartsWith("m_LocalPosition."))
     {
         if (binding.type == typeof(Transform))
         {
             return(RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "m_LocalPosition.", binding.type, 3));
         }
         return(null);
     }
     else
     {
         if (binding.propertyName.StartsWith("m_LocalScale."))
         {
             return(RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "m_LocalScale.", binding.type, 3));
         }
         if (!binding.propertyName.StartsWith("m_LocalRotation"))
         {
             return(null);
         }
         EditorCurveBinding binding2 = binding;
         binding2.propertyName = "localEulerAngles.x";
         if (AnimationUtility.GetEditorCurve(clip, binding2) != null)
         {
             return(RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "localEulerAngles.", binding.type, 3));
         }
         return(RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "localEulerAnglesBaked.", binding.type, 3));
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 public static EditorCurveBinding[] RemapAnimationBindingForAddKey(EditorCurveBinding binding, AnimationClip clip)
 {
     if (!AnimationWindowUtility.IsTransformType(binding.type))
     {
         return(null);
     }
     if (binding.propertyName.StartsWith("m_LocalPosition."))
     {
         if (binding.type == typeof(Transform))
         {
             return(RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "m_LocalPosition.", binding.type, 3));
         }
         return(null);
     }
     else
     {
         if (binding.propertyName.StartsWith("m_LocalScale."))
         {
             return(RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "m_LocalScale.", binding.type, 3));
         }
         if (binding.propertyName.StartsWith("m_LocalRotation"))
         {
             return(RotationCurveInterpolation.SelectRotationBindingForAddKey(binding, clip));
         }
         return(null);
     }
 }
コード例 #5
0
        private static EditorCurveBinding[] SelectRotationBindingForAddKey(EditorCurveBinding binding, AnimationClip clip)
        {
            EditorCurveBinding binding2 = binding;

            binding2.propertyName = "localEulerAnglesBaked.x";
            EditorCurveBinding[] result;
            if (AnimationUtility.GetEditorCurve(clip, binding2) != null)
            {
                result = RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "localEulerAnglesBaked.", binding.type, 3);
            }
            else
            {
                binding2.propertyName = "localEulerAngles.x";
                if (AnimationUtility.GetEditorCurve(clip, binding2) != null)
                {
                    result = RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "localEulerAngles.", binding.type, 3);
                }
                else
                {
                    binding2.propertyName = "localEulerAnglesRaw.x";
                    if (clip.legacy && AnimationUtility.GetEditorCurve(clip, binding2) == null)
                    {
                        result = RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "localEulerAnglesBaked.", binding.type, 3);
                    }
                    else
                    {
                        result = RotationCurveInterpolation.GenerateTransformCurveBindingArray(binding.path, "localEulerAnglesRaw.", binding.type, 3);
                    }
                }
            }
            return(result);
        }
コード例 #6
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);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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)]);
            }
        }
コード例 #9
0
 public static string GetPrefixForInterpolation(RotationCurveInterpolation.Mode newInterpolationMode)
 {
   if (newInterpolationMode == RotationCurveInterpolation.Mode.Baked)
     return "localEulerAnglesBaked";
   if (newInterpolationMode == RotationCurveInterpolation.Mode.NonBaked)
     return "localEulerAngles";
   if (newInterpolationMode == RotationCurveInterpolation.Mode.RawEuler)
     return "localEulerAnglesRaw";
   if (newInterpolationMode == RotationCurveInterpolation.Mode.RawQuaternions)
     return "m_LocalRotation";
   return (string) null;
 }
コード例 #10
0
 public static EditorCurveBinding[] RemapAnimationBindingForRotationAddKey(EditorCurveBinding binding, AnimationClip clip)
 {
     if (!AnimationWindowUtility.IsTransformType(binding.type))
     {
         return((EditorCurveBinding[])null);
     }
     if (binding.propertyName.StartsWith("m_LocalRotation"))
     {
         return(RotationCurveInterpolation.SelectRotationBindingForAddKey(binding, clip));
     }
     return((EditorCurveBinding[])null);
 }
コード例 #11
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)]);
            }
        }
コード例 #12
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;
 }
コード例 #13
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);
 }
コード例 #14
0
 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);
 }
コード例 #15
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);
        }
コード例 #16
0
        public static CurveRenderer GetCurveRenderer(AnimationClip clip, EditorCurveBinding curveBinding)
        {
            if (curveBinding.type == typeof(Transform) && curveBinding.propertyName.StartsWith("localEulerAngles."))
            {
                int    curveIndexFromName = RotationCurveInterpolation.GetCurveIndexFromName(curveBinding.propertyName);
                string key = CurveUtility.GetCurveGroupID(clip, curveBinding).ToString();
                EulerCurveCombinedRenderer eulerCurveCombinedRenderer = (EulerCurveCombinedRenderer)CurveRendererCache.m_CombiRenderers[key];
                if (eulerCurveCombinedRenderer == null)
                {
                    eulerCurveCombinedRenderer = new EulerCurveCombinedRenderer(AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "m_LocalRotation.x")), AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "m_LocalRotation.y")), AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "m_LocalRotation.z")), AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "m_LocalRotation.w")), AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "localEulerAngles.x")), AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "localEulerAngles.y")), AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve(curveBinding.path, typeof(Transform), "localEulerAngles.z")));
                    CurveRendererCache.m_CombiRenderers.Add(key, eulerCurveCombinedRenderer);
                }
                return(new EulerCurveRenderer(curveIndexFromName, eulerCurveCombinedRenderer));
            }
            string key2 = CurveUtility.GetCurveID(clip, curveBinding).ToString();
            NormalCurveRenderer normalCurveRenderer = (NormalCurveRenderer)CurveRendererCache.m_NormalRenderers[key2];

            if (normalCurveRenderer == null)
            {
                normalCurveRenderer = new NormalCurveRenderer(AnimationUtility.GetEditorCurve(clip, curveBinding));
                CurveRendererCache.m_NormalRenderers.Add(key2, normalCurveRenderer);
            }
            return(normalCurveRenderer);
        }
コード例 #17
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)]);
     }
   }
 }
コード例 #18
0
 internal static EditorCurveBinding[] ConvertRotationPropertiesToDefaultInterpolation(AnimationClip clip, EditorCurveBinding[] selection)
 {
     RotationCurveInterpolation.Mode newInterpolationMode = !clip.legacy ? RotationCurveInterpolation.Mode.RawEuler : RotationCurveInterpolation.Mode.Baked;
     return(RotationCurveInterpolation.ConvertRotationPropertiesToInterpolationType(selection, newInterpolationMode));
 }
コード例 #19
0
 private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
 {
   List<int> selectedIds = this.state.hierarchyState.selectedIDs;
   List<int> expandedIds = this.state.hierarchyState.expandedIDs;
   List<int> intList1 = new List<int>();
   List<int> intList2 = new List<int>();
   for (int index = 0; index < selectedIds.Count; ++index)
   {
     AnimationWindowHierarchyNode windowHierarchyNode = this.state.hierarchyData.FindItem(selectedIds[index]) as AnimationWindowHierarchyNode;
     if (windowHierarchyNode != null && !windowHierarchyNode.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
     {
       string oldValue = windowHierarchyNode.propertyName.Split('.')[0];
       string str = windowHierarchyNode.propertyName.Replace(oldValue, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));
       intList1.Add(selectedIds[index]);
       intList2.Add((windowHierarchyNode.path + windowHierarchyNode.animatableObjectType.Name + str).GetHashCode());
     }
   }
   for (int index1 = 0; index1 < intList1.Count; ++index1)
   {
     if (selectedIds.Contains(intList1[index1]))
     {
       int index2 = selectedIds.IndexOf(intList1[index1]);
       selectedIds[index2] = intList2[index1];
     }
     if (expandedIds.Contains(intList1[index1]))
     {
       int index2 = expandedIds.IndexOf(intList1[index1]);
       expandedIds[index2] = intList2[index1];
     }
     if (this.state.hierarchyState.lastClickedID == intList1[index1])
       this.state.hierarchyState.lastClickedID = intList2[index1];
   }
   this.state.hierarchyState.selectedIDs = new List<int>((IEnumerable<int>) selectedIds);
   this.state.hierarchyState.expandedIDs = new List<int>((IEnumerable<int>) expandedIds);
 }
コード例 #20
0
		private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
		{
			List<int> selectedIDs = this.state.m_hierarchyState.selectedIDs;
			List<int> expandedIDs = this.state.m_hierarchyState.expandedIDs;
			List<int> list = new List<int>();
			List<int> list2 = new List<int>();
			for (int i = 0; i < selectedIDs.Count; i++)
			{
				AnimationWindowHierarchyNode animationWindowHierarchyNode = this.state.m_HierarchyData.FindItem(selectedIDs[i]) as AnimationWindowHierarchyNode;
				if (animationWindowHierarchyNode != null && !animationWindowHierarchyNode.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
				{
					string oldValue = animationWindowHierarchyNode.propertyName.Split(new char[]
					{
						'.'
					})[0];
					string str = animationWindowHierarchyNode.propertyName.Replace(oldValue, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));
					list.Add(selectedIDs[i]);
					list2.Add((animationWindowHierarchyNode.path + animationWindowHierarchyNode.animatableObjectType.Name + str).GetHashCode());
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				if (selectedIDs.Contains(list[j]))
				{
					int index = selectedIDs.IndexOf(list[j]);
					selectedIDs[index] = list2[j];
				}
				if (expandedIDs.Contains(list[j]))
				{
					int index2 = expandedIDs.IndexOf(list[j]);
					expandedIDs[index2] = list2[j];
				}
				if (this.state.m_hierarchyState.lastClickedID == list[j])
				{
					this.state.m_hierarchyState.lastClickedID = list2[j];
				}
			}
			this.state.m_hierarchyState.selectedIDs = new List<int>(selectedIDs);
			this.state.m_hierarchyState.expandedIDs = new List<int>(expandedIDs);
		}
コード例 #21
0
 public static int GetCurveIndexFromName(string name)
 {
     return((int)RotationCurveInterpolation.ExtractComponentCharacter(name) - 120);
 }
コード例 #22
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)]);
                }
            }
        }
コード例 #23
0
 private void MaintainTreeviewStateAfterRotationInterpolation(RotationCurveInterpolation.Mode newMode)
 {
     List<int> selectedIDs = this.state.hierarchyState.selectedIDs;
     List<int> expandedIDs = this.state.hierarchyState.expandedIDs;
     List<int> list3 = new List<int>();
     List<int> list4 = new List<int>();
     for (int i = 0; i < selectedIDs.Count; i++)
     {
         AnimationWindowHierarchyNode node = this.state.hierarchyData.FindItem(selectedIDs[i]) as AnimationWindowHierarchyNode;
         if ((node != null) && !node.propertyName.Equals(RotationCurveInterpolation.GetPrefixForInterpolation(newMode)))
         {
             char[] separator = new char[] { '.' };
             string oldValue = node.propertyName.Split(separator)[0];
             string str2 = node.propertyName.Replace(oldValue, RotationCurveInterpolation.GetPrefixForInterpolation(newMode));
             list3.Add(selectedIDs[i]);
             list4.Add((node.path + node.animatableObjectType.Name + str2).GetHashCode());
         }
     }
     for (int j = 0; j < list3.Count; j++)
     {
         if (selectedIDs.Contains(list3[j]))
         {
             int index = selectedIDs.IndexOf(list3[j]);
             selectedIDs[index] = list4[j];
         }
         if (expandedIDs.Contains(list3[j]))
         {
             int num4 = expandedIDs.IndexOf(list3[j]);
             expandedIDs[num4] = list4[j];
         }
         if (this.state.hierarchyState.lastClickedID == list3[j])
         {
             this.state.hierarchyState.lastClickedID = list4[j];
         }
     }
     this.state.hierarchyState.selectedIDs = new List<int>(selectedIDs);
     this.state.hierarchyState.expandedIDs = new List<int>(expandedIDs);
 }
コード例 #24
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)]);
			}
		}
コード例 #25
0
		internal static EditorCurveBinding[] ConvertRotationPropertiesToInterpolationType(EditorCurveBinding[] selection, RotationCurveInterpolation.Mode newInterpolationMode)
		{
			if (selection.Length != 4)
			{
				return selection;
			}
			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";
				return array;
			}
			return selection;
		}
コード例 #26
0
 internal static EditorCurveBinding[] ConvertRotationPropertiesToDefaultInterpolation(AnimationClip clip, EditorCurveBinding[] selection)
 {
     return(RotationCurveInterpolation.ConvertRotationPropertiesToInterpolationType(selection, RotationCurveInterpolation.Mode.Baked));
 }