docs.unity.cn
    Show / Hide Table of Contents

    Class MarkerAction

    Base class for a marker action. Inherit from this class to make an action that would react on selected markers after a menu click and/or a key shortcut.

    Inheritance
    Object
    MarkerAction
    ReplaceAnnotationDescriptionAction
    Namespace: UnityEditor.Timeline.Actions
    Syntax
    public abstract class MarkerAction : object, IAction
    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.

    Examples

    Simple track Action example (with context menu and shortcut support).

        [MenuEntry("Custom Actions/Sample marker Action")]
        public class SampleMarkerAction : MarkerAction
        {
            public override ActionValidity Validate(IEnumerable<IMarker> markers)
            {
                return ActionValidity.Valid;
            }
    
            public override bool Execute(IEnumerable<IMarker> items)
            {
                Debug.Log("Test Action");
                return true;
            }
    
            [TimelineShortcut("SampleMarkerAction", KeyCode.L)]
            public static void HandleShortCut(ShortcutArguments args)
            {
                Invoker.InvokeWithSelectedMarkers<SampleMarkerAction>();
            }
        }

    Methods

    Execute(IEnumerable<IMarker>)

    Execute the action.

    Declaration
    public abstract bool Execute(IEnumerable<IMarker> markers)
    Parameters
    Type Name Description
    IEnumerable<IMarker> markers

    Markers that will be used for the action.

    Returns
    Type Description
    Boolean

    true if the action has been executed. false otherwise

    Validate(IEnumerable<IMarker>)

    Defines the validity of an Action for a given set of markers.

    Declaration
    public abstract ActionValidity Validate(IEnumerable<IMarker> markers)
    Parameters
    Type Name Description
    IEnumerable<IMarker> markers

    Markers that will be used for the action.

    Returns
    Type Description
    ActionValidity

    The validity of the set of markers.

    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Thursday, October 21, 2021