quot;{subtitle.template.speaker}: {subtitle.template.line}"; } public override ClipDrawOptions GetClipOptions(TimelineClip clip) { ClipDrawOptions options = base.GetClipOptions(clip); if (clip.asset is SubtitleClip subtitle) { options.tooltip = subtitle.template.line; float needed = subtitle.MinimumReadSeconds(); if (string.IsNullOrWhiteSpace(subtitle.template.line)) options.errorText = "Empty subtitle line."; else if (clip.duration < needed) options.errorText = quot;Too short to read: {clip.duration:0.0}s, needs about {needed:0.0}s."; } return options; } // Tint the part of the clip that is shorter than the reading-time guide. public override void DrawBackground(TimelineClip clip, ClipBackgroundRegion region) { base.DrawBackground(clip, region); if (clip.asset is not SubtitleClip subtitle) return; double needed = subtitle.MinimumReadSeconds(); if (clip.duration >= needed || region.endTime <= region.startTime) return; // The region is the visible part of the clip; draw over all of it. EditorGUI.DrawRect(region.position, k_TooShort); } } } ``` `ClipBackgroundRegion.position` is the clip's on-screen rectangle; `startTime` and `endTime` are the visible portion of the clip in clip time, which is why the draw is skipped when they collapse. ## 7.3 Marker editor: show what a skip keeps ```csharp // Assets/TimelineAdvanced/Editor/GameplayEventMarkerEditor.cs using UnityEditor; using UnityEditor.Timeline; using UnityEngine; using UnityEngine.Timeline; namespace TimelineAdvanced.Editor { [CustomTimelineEditor(typeof(GameplayEventMarker))] public class GameplayEventMarkerEditor : MarkerEditor { static readonly Color k_State = new Color(0.3f, 0.9f, 0.4f, 0.5f); static readonly Color k_Cosmetic = new Color(0.9f, 0.6f, 0.2f, 0.5f); public override MarkerDrawOptions GetMarkerOptions(IMarker marker) { MarkerDrawOptions options = base.GetMarkerOptions(marker); if (marker is GameplayEventMarker e) { string kind = e.changesGameState ? "state (fires on skip)" : "cosmetic (dropped on skip)"; options.tooltip = quot;{e.eventId} = {e.value} [{kind}]"; if (string.IsNullOrWhiteSpace(e.eventId)) options.errorText = "Gameplay Event has no eventId."; } return options; } // A thin vertical line through the timeline area, green for state events and // orange for cosmetic ones, so you can see at a glance what a skip will keep. public override void DrawOverlay(IMarker marker, MarkerUIStates uiState, MarkerOverlayRegion region) { if (marker is not GameplayEventMarker e) return; Rect markerRect = region.markerRegion; Rect line = new Rect(markerRect.center.x - 0.5f, region.timelineRegion.y, 1f, region.timelineRegion.height); EditorGUI.DrawRect(line, e.changesGameState ? k_State : k_Cosmetic); } } } ``` The overlay draws a 1 px line through the timeline area at each Gameplay Event: **green** for state events (kept on skip) and **orange** for cosmetic ones (dropped on skip). A designer can see at a glance what pressing Skip at any point will still do. For a fully custom marker *icon*, the Timeline custom marker workflow uses `[CustomStyle("StyleName")]` on the marker class plus a USS file at `Editor/Stylesheets/Extensions/common.uss` (and images under `Editor/Stylesheets/Resources`). That is not repeated here; follow the Notes marker workflow linked below if you want icons. ## 7.4 Checklist for any custom track - A `[DisplayName("Folder/Name")]` so it is grouped in the **+** menu. - `[TrackColor]` distinct from built-in tracks. - A `TrackEditor` error when the binding is missing or wrong. - A `ClipEditor` `displayName` that says what the clip does, not "LightIntensityClip". - `GatherProperties` if the mixer writes serialized component fields (part 2). - A restore path in `OnPlayableDestroy` (parts 2 and 3). ## 7.5 Exercise Give `LightIntensityTrackEditor` an `icon` (a 16x16 `Texture2D` loaded with `EditorGUIUtility.IconContent` or `AssetDatabase.LoadAssetAtPath`) and set `minimumHeight` so the clips are taller. Then add a `ClipEditor` for `LightIntensityClip` that draws the clip's `intensityOverClip` curve in `DrawBackground` with `Handles.DrawAAPolyLine`. ## Sources - `TrackEditor` (Timeline 1.8): https://docs.unity3d.com/Packages/[email protected]/api/UnityEditor.Timeline.TrackEditor.html - `ClipEditor` (Timeline 1.8): https://docs.unity3d.com/Packages/[email protected]/api/UnityEditor.Timeline.ClipEditor.html - `MarkerEditor` (Timeline 1.8): https://docs.unity3d.com/Packages/[email protected]/api/UnityEditor.Timeline.MarkerEditor.html - Create a custom marker (Notes marker, `DrawOverlay`, USS styles): https://docs.unity3d.com/Packages/[email protected]/manual/wf-custom-marker.html - Timeline Customization samples (Text clip editor, Annotation marker editor): https://docs.unity3d.com/Packages/[email protected]/manual/samp-custom-samples.html