// Creates a new annotation and add it to the selected track. public override bool Execute(ActionContext context) { // to find at which time to create a new marker, we need to consider how this action was invoked. // If the action was invoked by a context menu item, then we can use the context's invocation time. // If the action was invoked through a keyboard shortcut, we can use Timeline's playhead time instead. double time; if (context.invocationTime.HasValue) { time = context.invocationTime.Value; } else { time = TimelineEditor.inspectedDirector.time; } string clipboardTextContent = EditorGUIUtility.systemCopyBuffer; IEnumerable <TrackAsset> selectedTracks = context.tracks; foreach (TrackAsset track in selectedTracks) { if (track is GroupTrack) { continue; } AnnotationMarker annotation = track.CreateMarker <AnnotationMarker>(time); annotation.description = clipboardTextContent; annotation.title = "Annotation"; } return(true); }
// Sets the marker's tooltip based on its title. public override MarkerDrawOptions GetMarkerOptions(IMarker marker) { // The `marker argument needs to be cast as the appropriate type, usually the one specified in the `CustomTimelineEditor` attribute AnnotationMarker annotation = marker as AnnotationMarker; if (annotation == null) { return(base.GetMarkerOptions(marker)); } return(new MarkerDrawOptions { tooltip = annotation.title }); }
// Draws a vertical line on top of the Timeline window's contents. public override void DrawOverlay(IMarker marker, MarkerUIStates uiState, MarkerOverlayRegion region) { // The `marker argument needs to be cast as the appropriate type, usually the one specified in the `CustomTimelineEditor` attribute AnnotationMarker annotation = marker as AnnotationMarker; if (annotation == null) { return; } if (annotation.showLineOverlay) { DrawLineOverlay(annotation.color, region); } DrawColorOverlay(region, annotation.color, uiState); }