Пример #1
0
        private void HandleEvent()
        {
            var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1;

            if (!isContext)
            {
                return;
            }

            var contextMenu = new GenericMenu();

            if (SelectedObjects.Count == 0 || GetSelectableObjectUnderPos(Event.current.mousePosition).Count == 0)
            {
                var newTime = ((Event.current.mousePosition.x + XScroll) / (DisplayArea.width * XScale)) * Duration;
                contextMenu.AddItem(new GUIContent("Add Key"), false, () => { AddKeyframeAtTime(newTime); });
            }

            if (SelectedObjects.Count != 0)
            {
                var keyframe = SelectedObjects[0] as USInternalKeyframe;

                contextMenu.AddItem(new GUIContent("Remove Key"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => RemoveKeyframe(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });
                contextMenu.AddSeparator("");

                contextMenu.AddItem(new GUIContent("Broken"), keyframe.BrokenTangents, () => { SelectedObjects.ForEach((selectedKeyframe) => BreakKeyframeTangents(selectedKeyframe as USInternalKeyframe, keyframe.BrokenTangents)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });

                contextMenu.AddItem(new GUIContent("Smooth"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => SmoothKeyframe(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });
                contextMenu.AddItem(new GUIContent("Flatten"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => FlattenKeyframe(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });

                contextMenu.AddItem(new GUIContent("Right Tangent/Linear"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => RightKeyframeTangentLinear(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });
                contextMenu.AddItem(new GUIContent("Right Tangent/Constant"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => RightKeyframeTangentConstant(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });
                contextMenu.AddItem(new GUIContent("Left Tangent/Linear"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => LeftKeyframeTangentLinear(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });
                contextMenu.AddItem(new GUIContent("Left Tangent/Constant"), false, () => { SelectedObjects.ForEach((selectedKeyframe) => LeftKeyframeTangentConstant(selectedKeyframe as USInternalKeyframe)); RebuildCachedCurveInformation(); AreCurvesDirty = true; });
            }

            if (contextMenu.GetItemCount() > 0)
            {
                Event.current.Use();
                contextMenu.ShowAsContext();
            }
        }
Пример #2
0
 public static void ClearSelection()
 {
     SelectedObjects.ForEach(x => (x.UserObject as ISelectable).Model.RenderFlags &= ~RenderFlags.Selected);
     SelectedObjects.Clear();
 }