ActionExamples.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEditor.ShortcutManagement;
  4. using UnityEditor.Timeline.Actions;
  5. using UnityEngine;
  6. using UnityEngine.Timeline;
  7. namespace DocCodeExamples
  8. {
  9. class ActionExamples_HideAPI
  10. {
  11. #region declare-sampleClipAction
  12. [MenuEntry("Custom Actions/Sample clip Action")]
  13. public class SampleClipAction : ClipAction
  14. {
  15. public override ActionValidity Validate(IEnumerable<TimelineClip> clip)
  16. {
  17. return ActionValidity.Valid;
  18. }
  19. public override bool Execute(IEnumerable<TimelineClip> items)
  20. {
  21. Debug.Log("Test Action");
  22. return true;
  23. }
  24. [TimelineShortcut("SampleClipAction", KeyCode.K)]
  25. public static void HandleShortCut(ShortcutArguments args)
  26. {
  27. Invoker.InvokeWithSelectedClips<SampleClipAction>();
  28. }
  29. }
  30. #endregion
  31. #region declare-sampleMarkerAction
  32. [MenuEntry("Custom Actions/Sample marker Action")]
  33. public class SampleMarkerAction : MarkerAction
  34. {
  35. public override ActionValidity Validate(IEnumerable<IMarker> markers)
  36. {
  37. return ActionValidity.Valid;
  38. }
  39. public override bool Execute(IEnumerable<IMarker> items)
  40. {
  41. Debug.Log("Test Action");
  42. return true;
  43. }
  44. [TimelineShortcut("SampleMarkerAction", KeyCode.L)]
  45. public static void HandleShortCut(ShortcutArguments args)
  46. {
  47. Invoker.InvokeWithSelectedMarkers<SampleMarkerAction>();
  48. }
  49. }
  50. #endregion
  51. #region declare-sampleTrackAction
  52. [MenuEntry("Custom Actions/Sample track Action")]
  53. public class SampleTrackAction : TrackAction
  54. {
  55. public override ActionValidity Validate(IEnumerable<TrackAsset> tracks)
  56. {
  57. return ActionValidity.Valid;
  58. }
  59. public override bool Execute(IEnumerable<TrackAsset> tracks)
  60. {
  61. Debug.Log("Test Action");
  62. return true;
  63. }
  64. [TimelineShortcut("SampleTrackAction", KeyCode.H)]
  65. public static void HandleShortCut(ShortcutArguments args)
  66. {
  67. Invoker.InvokeWithSelectedTracks<SampleTrackAction>();
  68. }
  69. }
  70. #endregion
  71. #region declare-sampleTimelineAction
  72. [MenuEntry("Custom Actions/Sample Timeline Action")]
  73. public class SampleTimelineAction : TimelineAction
  74. {
  75. public override ActionValidity Validate(ActionContext context)
  76. {
  77. return ActionValidity.Valid;
  78. }
  79. public override bool Execute(ActionContext context)
  80. {
  81. Debug.Log("Test Action");
  82. return true;
  83. }
  84. [TimelineShortcut("SampleTimelineAction", KeyCode.Q)]
  85. public static void HandleShortCut(ShortcutArguments args)
  86. {
  87. Invoker.InvokeWithSelected<SampleTimelineAction>();
  88. }
  89. }
  90. #endregion
  91. }
  92. }