Class TrackAction
Base class for a track action. Inherit from this class to make an action that would react on selected tracks after a menu click and/or a key shortcut.
Inherited Members
Namespace: UnityEditor.Timeline.Actions
Assembly: solution.dll
Syntax
[ActiveInMode(TimelineModes.Default)]
public abstract class TrackAction
Remarks
To add an action as a menu item in the Timeline context menu, add MenuEntryAttribute on the action class. To make an action to react to a shortcut, use the Shortcut Manager API with TimelineShortcutAttribute. ShortcutAttribute
Examples
Simple track Action example (with context menu and shortcut support).
[MenuEntry("Custom Actions/Sample track Action")]
public class SampleTrackAction : TrackAction
{
public abstract ActionValidity Validate(IEnumerable<TrackAsset> items)
{
return ActionValidity.Valid;
}
public override bool Execute(IEnumerable<TrackAsset> items)
{
Debug.Log("Test Action");
return true;
}
[TimelineShortcut("SampleTrackAction", KeyCode.K), UsedImplicitly]
public static void HandleShortCut(ShortcutArguments args)
{
Action.InvokeWithSelectedTracks<SampleTrackAction> ();
}
}
Methods
Name | Description |
---|---|
Execute(IEnumerable<TrackAsset>) | Execute the action. |
Validate(IEnumerable<TrackAsset>) | Defines the validity of an Action for a given set of tracks. |