private GenericMenu GenerateMenu(DopeLine dopeline, bool clickedEmpty) { GenericMenu genericMenu = new GenericMenu(); if (AnimationMode.InAnimationMode()) { string text = "Add Key"; if (clickedEmpty) { genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeyToDopeline), dopeline); } else { genericMenu.AddDisabledItem(new GUIContent(text)); } text = ((this.state.selectedKeys.Count <= 1) ? "Delete Key" : "Delete Keys"); if (this.state.selectedKeys.Count > 0) { genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction(this.DeleteSelectedKeys)); } else { genericMenu.AddDisabledItem(new GUIContent(text)); } if (AnimationWindowUtility.ContainsFloatKeyframes(this.state.selectedKeys)) { genericMenu.AddSeparator(string.Empty); List<KeyIdentifier> list = new List<KeyIdentifier>(); foreach (AnimationWindowKeyframe current in this.state.selectedKeys) { if (!current.isPPtrCurve) { int keyframeIndex = current.curve.GetKeyframeIndex(AnimationKeyTime.Time(current.time, this.state.frameRate)); if (keyframeIndex != -1) { CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.m_ActiveAnimationClip, current.curve.binding); int curveID = CurveUtility.GetCurveID(this.state.m_ActiveAnimationClip, current.curve.binding); list.Add(new KeyIdentifier(curveRenderer, curveID, keyframeIndex)); } } } CurveMenuManager curveMenuManager = new CurveMenuManager(this.state.m_AnimationWindow); curveMenuManager.AddTangentMenuItems(genericMenu, list); } } return genericMenu; }
private GenericMenu GenerateMenu(List<AnimationWindowHierarchyNode> interactedNodes) { List<AnimationWindowCurve> curvesAffectedByNodes = this.GetCurvesAffectedByNodes(interactedNodes, false); List<AnimationWindowCurve> curvesAffectedByNodes2 = this.GetCurvesAffectedByNodes(interactedNodes, true); bool flag = curvesAffectedByNodes.Count == 1 && AnimationWindowUtility.ForceGrouping(curvesAffectedByNodes[0].binding); GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent((curvesAffectedByNodes.Count <= 1 && !flag) ? "Remove Property" : "Remove Properties"), false, new GenericMenu.MenuFunction(this.RemoveCurvesFromSelectedNodes)); bool flag2 = true; EditorCurveBinding[] array = new EditorCurveBinding[curvesAffectedByNodes2.Count]; for (int i = 0; i < curvesAffectedByNodes2.Count; i++) { array[i] = curvesAffectedByNodes2[i].binding; } RotationCurveInterpolation.Mode rotationInterpolationMode = this.GetRotationInterpolationMode(array); if (rotationInterpolationMode == RotationCurveInterpolation.Mode.Undefined) { flag2 = false; } else { foreach (AnimationWindowHierarchyNode current in interactedNodes) { if (!(current is AnimationWindowHierarchyPropertyGroupNode)) { flag2 = false; } } } if (flag2) { genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles"), rotationInterpolationMode == RotationCurveInterpolation.Mode.Baked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.Baked); genericMenu.AddItem(new GUIContent("Interpolation/Quaternion"), rotationInterpolationMode == RotationCurveInterpolation.Mode.NonBaked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.NonBaked); } if (AnimationMode.InAnimationMode()) { genericMenu.AddSeparator(string.Empty); bool flag3 = true; bool flag4 = true; bool flag5 = true; foreach (AnimationWindowCurve current2 in curvesAffectedByNodes) { if (!current2.HasKeyframe(this.state.time)) { flag3 = false; } else { flag4 = false; if (!current2.isPPtrCurve) { flag5 = false; } } } string text = "Add Key"; if (flag3) { genericMenu.AddDisabledItem(new GUIContent(text)); } else { genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeysAtCurrentTime), curvesAffectedByNodes); } text = "Delete Key"; if (flag4) { genericMenu.AddDisabledItem(new GUIContent(text)); } else { genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtCurrentTime), curvesAffectedByNodes); } if (!flag5) { genericMenu.AddSeparator(string.Empty); List<KeyIdentifier> list = new List<KeyIdentifier>(); foreach (AnimationWindowCurve current3 in curvesAffectedByNodes) { if (!current3.isPPtrCurve) { int keyframeIndex = current3.GetKeyframeIndex(this.state.time); if (keyframeIndex != -1) { CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.m_ActiveAnimationClip, current3.binding); int curveID = CurveUtility.GetCurveID(this.state.m_ActiveAnimationClip, current3.binding); list.Add(new KeyIdentifier(curveRenderer, curveID, keyframeIndex)); } } } CurveMenuManager curveMenuManager = new CurveMenuManager(this.state.m_AnimationWindow); curveMenuManager.AddTangentMenuItems(genericMenu, list); } } return genericMenu; }