private void RemoveCurvesFromNodes(List <AnimationWindowHierarchyNode> nodes) { foreach (AnimationWindowHierarchyNode current in nodes) { AnimationWindowHierarchyNode animationWindowHierarchyNode = current; if (animationWindowHierarchyNode.parent is AnimationWindowHierarchyPropertyGroupNode) { EditorCurveBinding?binding = animationWindowHierarchyNode.binding; if (binding.HasValue) { EditorCurveBinding?binding2 = animationWindowHierarchyNode.binding; if (AnimationWindowUtility.ForceGrouping(binding2.Value)) { animationWindowHierarchyNode = (AnimationWindowHierarchyNode)animationWindowHierarchyNode.parent; } } } List <AnimationWindowCurve> list; if (animationWindowHierarchyNode is AnimationWindowHierarchyPropertyGroupNode || animationWindowHierarchyNode is AnimationWindowHierarchyPropertyNode) { list = AnimationWindowUtility.FilterCurves(this.state.allCurves.ToArray(), animationWindowHierarchyNode.path, animationWindowHierarchyNode.animatableObjectType, animationWindowHierarchyNode.propertyName); } else { list = AnimationWindowUtility.FilterCurves(this.state.allCurves.ToArray(), animationWindowHierarchyNode.path, animationWindowHierarchyNode.animatableObjectType); } foreach (AnimationWindowCurve current2 in list) { this.state.RemoveCurve(current2); } } this.m_TreeView.ReloadData(); }
private void RemoveCurvesFromNodes(List <AnimationWindowHierarchyNode> nodes) { string undoLabel = "Remove Curve"; this.state.SaveKeySelection(undoLabel); foreach (AnimationWindowHierarchyNode current in nodes) { AnimationWindowHierarchyNode animationWindowHierarchyNode = current; if (animationWindowHierarchyNode.parent is AnimationWindowHierarchyPropertyGroupNode) { EditorCurveBinding?binding = animationWindowHierarchyNode.binding; if (binding.HasValue) { EditorCurveBinding?binding2 = animationWindowHierarchyNode.binding; if (AnimationWindowUtility.ForceGrouping(binding2.Value)) { animationWindowHierarchyNode = (AnimationWindowHierarchyNode)animationWindowHierarchyNode.parent; } } } if (animationWindowHierarchyNode.curves != null) { List <AnimationWindowCurve> list; if (animationWindowHierarchyNode is AnimationWindowHierarchyPropertyGroupNode || animationWindowHierarchyNode is AnimationWindowHierarchyPropertyNode) { list = AnimationWindowUtility.FilterCurves(animationWindowHierarchyNode.curves.ToArray <AnimationWindowCurve>(), animationWindowHierarchyNode.path, animationWindowHierarchyNode.animatableObjectType, animationWindowHierarchyNode.propertyName); } else { list = AnimationWindowUtility.FilterCurves(animationWindowHierarchyNode.curves.ToArray <AnimationWindowCurve>(), animationWindowHierarchyNode.path, animationWindowHierarchyNode.animatableObjectType); } foreach (AnimationWindowCurve current2 in list) { this.state.RemoveCurve(current2, undoLabel); } } } this.m_TreeView.ReloadData(); if (this.state.recording) { this.state.ResampleAnimation(); } }
private void RemoveCurvesFromNodes(List <AnimationWindowHierarchyNode> nodes) { string undoLabel = "Remove Curve"; state.SaveKeySelection(undoLabel); foreach (var node in nodes) { AnimationWindowHierarchyNode hierarchyNode = (AnimationWindowHierarchyNode)node; if (hierarchyNode.parent is AnimationWindowHierarchyPropertyGroupNode && hierarchyNode.binding != null && AnimationWindowUtility.ForceGrouping((EditorCurveBinding)hierarchyNode.binding)) { hierarchyNode = (AnimationWindowHierarchyNode)hierarchyNode.parent; } if (hierarchyNode.curves == null) { continue; } List <AnimationWindowCurve> curves = null; // Property or propertygroup if (hierarchyNode is AnimationWindowHierarchyPropertyGroupNode || hierarchyNode is AnimationWindowHierarchyPropertyNode) { curves = AnimationWindowUtility.FilterCurves(hierarchyNode.curves.ToArray(), hierarchyNode.path, hierarchyNode.animatableObjectType, hierarchyNode.propertyName); } else { curves = AnimationWindowUtility.FilterCurves(hierarchyNode.curves.ToArray(), hierarchyNode.path, hierarchyNode.animatableObjectType); } foreach (AnimationWindowCurve animationWindowCurve in curves) { state.RemoveCurve(animationWindowCurve, undoLabel); } } m_TreeView.ReloadData(); state.controlInterface.ResampleAnimation(); }
private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes, bool enabled) { List <AnimationWindowCurve> curves = GetCurvesAffectedByNodes(interactedNodes, false); // Linked curves are like regular affected curves but always include transform siblings List <AnimationWindowCurve> linkedCurves = GetCurvesAffectedByNodes(interactedNodes, true); bool forceGroupRemove = curves.Count == 1 ? AnimationWindowUtility.ForceGrouping(curves[0].binding) : false; GenericMenu menu = new GenericMenu(); // Remove curves GUIContent removePropertyContent = new GUIContent(curves.Count > 1 || forceGroupRemove ? "Remove Properties" : "Remove Property"); if (!enabled) { menu.AddDisabledItem(removePropertyContent); } else { menu.AddItem(removePropertyContent, false, RemoveCurvesFromSelectedNodes); } // Change rotation interpolation bool showInterpolation = true; EditorCurveBinding[] curveBindings = new EditorCurveBinding[linkedCurves.Count]; for (int i = 0; i < linkedCurves.Count; i++) { curveBindings[i] = linkedCurves[i].binding; } RotationCurveInterpolation.Mode rotationInterpolation = GetRotationInterpolationMode(curveBindings); if (rotationInterpolation == RotationCurveInterpolation.Mode.Undefined) { showInterpolation = false; } else { foreach (var node in interactedNodes) { if (!(node is AnimationWindowHierarchyPropertyGroupNode)) { showInterpolation = false; } } } if (showInterpolation) { string legacyWarning = state.activeAnimationClip.legacy ? " (Not fully supported in Legacy)" : ""; GenericMenu.MenuFunction2 nullMenuFunction2 = null; menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Euler Angles" + legacyWarning), rotationInterpolation == RotationCurveInterpolation.Mode.RawEuler, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.RawEuler); menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Euler Angles (Quaternion)"), rotationInterpolation == RotationCurveInterpolation.Mode.Baked, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.Baked); menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Quaternion"), rotationInterpolation == RotationCurveInterpolation.Mode.NonBaked, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.NonBaked); } // Menu items that are only applicaple when in animation mode: if (state.previewing) { menu.AddSeparator(""); bool allHaveKeys = true; bool noneHaveKeys = true; foreach (AnimationWindowCurve curve in curves) { bool curveHasKey = curve.HasKeyframe(state.time); if (!curveHasKey) { allHaveKeys = false; } else { noneHaveKeys = false; } } string str; str = "Add Key"; if (allHaveKeys || !enabled) { menu.AddDisabledItem(new GUIContent(str)); } else { menu.AddItem(new GUIContent(str), false, AddKeysAtCurrentTime, curves); } str = "Delete Key"; if (noneHaveKeys || !enabled) { menu.AddDisabledItem(new GUIContent(str)); } else { menu.AddItem(new GUIContent(str), false, DeleteKeysAtCurrentTime, curves); } } return(menu); }
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) { string str = (!this.state.activeAnimationClip.legacy) ? string.Empty : " (Not fully supported in Legacy)"; genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles" + str), rotationInterpolationMode == RotationCurveInterpolation.Mode.RawEuler, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.RawEuler); genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles (Quaternion)"), 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; foreach (AnimationWindowCurve current2 in curvesAffectedByNodes) { if (!current2.HasKeyframe(this.state.time)) { flag3 = false; } else { flag4 = 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); } } return(genericMenu); }
private void RemoveCurvesFromNodes(List <AnimationWindowHierarchyNode> nodes) { foreach (AnimationWindowHierarchyNode node in nodes) { AnimationWindowHierarchyNode parent = node; if (((parent.parent is AnimationWindowHierarchyPropertyGroupNode) && parent.binding.HasValue) && AnimationWindowUtility.ForceGrouping(parent.binding.Value)) { parent = (AnimationWindowHierarchyNode)parent.parent; } List <AnimationWindowCurve> list = null; if ((parent is AnimationWindowHierarchyPropertyGroupNode) || (parent is AnimationWindowHierarchyPropertyNode)) { list = AnimationWindowUtility.FilterCurves(this.state.allCurves.ToArray(), parent.path, parent.animatableObjectType, parent.propertyName); } else { list = AnimationWindowUtility.FilterCurves(this.state.allCurves.ToArray(), parent.path, parent.animatableObjectType); } foreach (AnimationWindowCurve curve in list) { this.state.RemoveCurve(curve); } } base.m_TreeView.ReloadData(); }
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); }
private void RemoveCurvesFromNodes(List <AnimationWindowHierarchyNode> nodes) { using (List <AnimationWindowHierarchyNode> .Enumerator enumerator1 = nodes.GetEnumerator()) { while (enumerator1.MoveNext()) { AnimationWindowHierarchyNode windowHierarchyNode = enumerator1.Current; if (windowHierarchyNode.parent is AnimationWindowHierarchyPropertyGroupNode && windowHierarchyNode.binding.HasValue && AnimationWindowUtility.ForceGrouping(windowHierarchyNode.binding.Value)) { windowHierarchyNode = (AnimationWindowHierarchyNode)windowHierarchyNode.parent; } using (List <AnimationWindowCurve> .Enumerator enumerator2 = (windowHierarchyNode is AnimationWindowHierarchyPropertyGroupNode || windowHierarchyNode is AnimationWindowHierarchyPropertyNode ? AnimationWindowUtility.FilterCurves(this.state.allCurves.ToArray(), windowHierarchyNode.path, windowHierarchyNode.animatableObjectType, windowHierarchyNode.propertyName) : AnimationWindowUtility.FilterCurves(this.state.allCurves.ToArray(), windowHierarchyNode.path, windowHierarchyNode.animatableObjectType)).GetEnumerator()) { while (enumerator2.MoveNext()) { this.state.RemoveCurve(enumerator2.Current); } } } } this.m_TreeView.ReloadData(); }
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); }