private void Refresh()
 {
     if (this.refresh == AnimationWindowState.RefreshType.Everything)
     {
         CurveRendererCache.ClearCurveRendererCache();
         this.m_ActiveKeyframeCache = null;
         this.m_AllCurvesCache      = null;
         this.m_ActiveCurvesCache   = null;
         this.m_CurveEditorIsDirty  = true;
         this.m_dopelinesCache      = null;
         this.m_SelectedKeysCache   = null;
         if (this.refresh == AnimationWindowState.RefreshType.Everything && this.m_HierarchyData != null)
         {
             this.m_HierarchyData.UpdateData();
         }
         EditorCurveBinding?lastAddedCurveBinding = this.m_lastAddedCurveBinding;
         if (lastAddedCurveBinding.HasValue)
         {
             EditorCurveBinding?lastAddedCurveBinding2 = this.m_lastAddedCurveBinding;
             this.OnNewCurveAdded(lastAddedCurveBinding2.Value);
         }
         if (this.activeCurves.Count == 0 && this.dopelines.Count > 0)
         {
             this.SelectHierarchyItem(this.dopelines[0], false, false);
         }
         this.m_Refresh = AnimationWindowState.RefreshType.None;
     }
     else
     {
         if (this.refresh == AnimationWindowState.RefreshType.CurvesOnly)
         {
             this.m_ActiveKeyframeCache = null;
             this.m_ActiveCurvesCache   = null;
             this.m_SelectedKeysCache   = null;
             this.ReloadModifiedAnimationCurveCache();
             this.ReloadModifiedDopelineCache();
             CurveRendererCache.ClearCurveRendererCache();
             this.m_CurveEditorIsDirty = true;
             this.m_Refresh            = AnimationWindowState.RefreshType.None;
             this.m_ModifiedCurves.Clear();
         }
     }
 }
        private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes)
        {
            List <AnimationWindowCurve> curvesAffectedByNodes = this.GetCurvesAffectedByNodes(interactedNodes, false);
            List <AnimationWindowCurve> list2 = this.GetCurvesAffectedByNodes(interactedNodes, true);
            bool        flag = (curvesAffectedByNodes.Count == 1) && AnimationWindowUtility.ForceGrouping(curvesAffectedByNodes[0].binding);
            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent(((curvesAffectedByNodes.Count <= 1) && !flag) ? "Remove Property" : "Remove Properties"), false, new GenericMenu.MenuFunction(this.RemoveCurvesFromSelectedNodes));
            bool flag2 = true;

            EditorCurveBinding[] curves = new EditorCurveBinding[list2.Count];
            for (int i = 0; i < list2.Count; i++)
            {
                curves[i] = list2[i].binding;
            }
            RotationCurveInterpolation.Mode rotationInterpolationMode = this.GetRotationInterpolationMode(curves);
            if (rotationInterpolationMode == RotationCurveInterpolation.Mode.Undefined)
            {
                flag2 = false;
            }
            else
            {
                foreach (AnimationWindowHierarchyNode node in interactedNodes)
                {
                    if (!(node is AnimationWindowHierarchyPropertyGroupNode))
                    {
                        flag2 = false;
                    }
                }
            }
            if (flag2)
            {
                menu.AddItem(new GUIContent("Interpolation/Euler Angles"), rotationInterpolationMode == RotationCurveInterpolation.Mode.RawEuler, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.RawEuler);
                menu.AddItem(new GUIContent("Interpolation/Euler Angles (Quaternion Approximation)"), rotationInterpolationMode == RotationCurveInterpolation.Mode.Baked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.Baked);
                menu.AddItem(new GUIContent("Interpolation/Quaternion"), rotationInterpolationMode == RotationCurveInterpolation.Mode.NonBaked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.NonBaked);
            }
            if (AnimationMode.InAnimationMode())
            {
                menu.AddSeparator(string.Empty);
                bool flag3 = true;
                bool flag4 = true;
                bool flag5 = true;
                foreach (AnimationWindowCurve curve in curvesAffectedByNodes)
                {
                    if (!curve.HasKeyframe(this.state.time))
                    {
                        flag3 = false;
                    }
                    else
                    {
                        flag4 = false;
                        if (!curve.isPPtrCurve)
                        {
                            flag5 = false;
                        }
                    }
                }
                string text = "Add Key";
                if (flag3)
                {
                    menu.AddDisabledItem(new GUIContent(text));
                }
                else
                {
                    menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeysAtCurrentTime), curvesAffectedByNodes);
                }
                text = "Delete Key";
                if (flag4)
                {
                    menu.AddDisabledItem(new GUIContent(text));
                }
                else
                {
                    menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtCurrentTime), curvesAffectedByNodes);
                }
                if (flag5)
                {
                    return(menu);
                }
                menu.AddSeparator(string.Empty);
                List <KeyIdentifier> list3 = new List <KeyIdentifier>();
                foreach (AnimationWindowCurve curve2 in curvesAffectedByNodes)
                {
                    if (!curve2.isPPtrCurve)
                    {
                        int keyframeIndex = curve2.GetKeyframeIndex(this.state.time);
                        if (keyframeIndex != -1)
                        {
                            CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.activeAnimationClip, curve2.binding);
                            int           curveID       = CurveUtility.GetCurveID(this.state.activeAnimationClip, curve2.binding);
                            list3.Add(new KeyIdentifier(curveRenderer, curveID, keyframeIndex));
                        }
                    }
                }
            }
            return(menu);
        }
Exemple #3
0
        private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes)
        {
            List <AnimationWindowCurve> curvesAffectedByNodes1 = this.GetCurvesAffectedByNodes(interactedNodes, false);
            List <AnimationWindowCurve> curvesAffectedByNodes2 = this.GetCurvesAffectedByNodes(interactedNodes, true);
            bool        flag1       = curvesAffectedByNodes1.Count == 1 && AnimationWindowUtility.ForceGrouping(curvesAffectedByNodes1[0].binding);
            GenericMenu genericMenu = new GenericMenu();

            genericMenu.AddItem(new GUIContent(curvesAffectedByNodes1.Count > 1 || flag1 ? "Remove Properties" : "Remove Property"), false, new GenericMenu.MenuFunction(this.RemoveCurvesFromSelectedNodes));
            bool flag2 = true;

            EditorCurveBinding[] curves = new EditorCurveBinding[curvesAffectedByNodes2.Count];
            for (int index = 0; index < curvesAffectedByNodes2.Count; ++index)
            {
                curves[index] = curvesAffectedByNodes2[index].binding;
            }
            RotationCurveInterpolation.Mode interpolationMode = this.GetRotationInterpolationMode(curves);
            if (interpolationMode == RotationCurveInterpolation.Mode.Undefined)
            {
                flag2 = false;
            }
            else
            {
                using (List <AnimationWindowHierarchyNode> .Enumerator enumerator = interactedNodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (!(enumerator.Current is AnimationWindowHierarchyPropertyGroupNode))
                        {
                            flag2 = false;
                        }
                    }
                }
            }
            if (flag2)
            {
                string str = !this.state.activeAnimationClip.legacy ? string.Empty : " (Not fully supported in Legacy)";
                genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles" + str), interpolationMode == RotationCurveInterpolation.Mode.RawEuler, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), (object)RotationCurveInterpolation.Mode.RawEuler);
                genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles (Quaternion Approximation)"), interpolationMode == RotationCurveInterpolation.Mode.Baked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), (object)RotationCurveInterpolation.Mode.Baked);
                genericMenu.AddItem(new GUIContent("Interpolation/Quaternion"), interpolationMode == RotationCurveInterpolation.Mode.NonBaked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), (object)RotationCurveInterpolation.Mode.NonBaked);
            }
            if (AnimationMode.InAnimationMode())
            {
                genericMenu.AddSeparator(string.Empty);
                bool flag3 = true;
                bool flag4 = true;
                bool flag5 = true;
                using (List <AnimationWindowCurve> .Enumerator enumerator = curvesAffectedByNodes1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AnimationWindowCurve current = enumerator.Current;
                        if (!current.HasKeyframe(this.state.time))
                        {
                            flag3 = false;
                        }
                        else
                        {
                            flag4 = false;
                            if (!current.isPPtrCurve)
                            {
                                flag5 = false;
                            }
                        }
                    }
                }
                string text1 = "Add Key";
                if (flag3)
                {
                    genericMenu.AddDisabledItem(new GUIContent(text1));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent(text1), false, new GenericMenu.MenuFunction2(this.AddKeysAtCurrentTime), (object)curvesAffectedByNodes1);
                }
                string text2 = "Delete Key";
                if (flag4)
                {
                    genericMenu.AddDisabledItem(new GUIContent(text2));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent(text2), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtCurrentTime), (object)curvesAffectedByNodes1);
                }
                if (!flag5)
                {
                    genericMenu.AddSeparator(string.Empty);
                    List <KeyIdentifier> keyIdentifierList = new List <KeyIdentifier>();
                    using (List <AnimationWindowCurve> .Enumerator enumerator = curvesAffectedByNodes1.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            AnimationWindowCurve current = enumerator.Current;
                            if (!current.isPPtrCurve)
                            {
                                int keyframeIndex = current.GetKeyframeIndex(this.state.time);
                                if (keyframeIndex != -1)
                                {
                                    CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.activeAnimationClip, current.binding);
                                    int           curveId       = CurveUtility.GetCurveID(this.state.activeAnimationClip, current.binding);
                                    keyIdentifierList.Add(new KeyIdentifier(curveRenderer, curveId, keyframeIndex));
                                }
                            }
                        }
                    }
                }
            }
            return(genericMenu);
        }