ManipulationsClips.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Linq;
  2. using UnityEngine;
  3. using UnityEngine.Timeline;
  4. namespace UnityEditor.Timeline
  5. {
  6. class ItemActionShortcutManipulator : Manipulator
  7. {
  8. protected override bool ExecuteCommand(Event evt, WindowState state)
  9. {
  10. if (state.IsEditingASubItem())
  11. return false;
  12. var consumed = false;
  13. var clips = SelectionManager.SelectedClips();
  14. foreach (var clip in clips)
  15. consumed |= ItemAction<TimelineClip>.HandleShortcut(state, evt, clip);
  16. var markers = SelectionManager.SelectedMarkers();
  17. foreach (var marker in markers)
  18. consumed |= ItemAction<IMarker>.HandleShortcut(state, evt, marker);
  19. return consumed;
  20. }
  21. }
  22. class DrillIntoClip : Manipulator
  23. {
  24. protected override bool DoubleClick(Event evt, WindowState state)
  25. {
  26. if (evt.button != 0)
  27. return false;
  28. var guiClip = PickerUtils.PickedLayerableOfType<TimelineClipGUI>();
  29. if (guiClip == null)
  30. return false;
  31. if (!TimelineWindow.instance.state.editSequence.isReadOnly && (guiClip.clip.curves != null || guiClip.clip.animationClip != null))
  32. ItemAction<TimelineClip>.Invoke<EditClipInAnimationWindow>(state, guiClip.clip);
  33. if (guiClip.supportsSubTimelines)
  34. ItemAction<TimelineClip>.Invoke<EditSubTimeline>(state, guiClip.clip);
  35. return true;
  36. }
  37. }
  38. class ContextMenuManipulator : Manipulator
  39. {
  40. protected override bool MouseDown(Event evt, WindowState state)
  41. {
  42. if (evt.button == 1)
  43. ItemSelection.HandleSingleSelection(evt);
  44. return false;
  45. }
  46. protected override bool ContextClick(Event evt, WindowState state)
  47. {
  48. if (evt.alt)
  49. return false;
  50. var selectable = PickerUtils.PickedLayerableOfType<ISelectable>();
  51. if (selectable != null && selectable.IsSelected())
  52. {
  53. SequencerContextMenu.ShowItemContextMenu(evt.mousePosition,
  54. SelectionManager.SelectedClips().ToArray(),
  55. SelectionManager.SelectedMarkers().ToArray());
  56. return true;
  57. }
  58. return false;
  59. }
  60. }
  61. }