Custom MarkerTrack not being called

Hi, I’m trying to override MarkerTrack, but its methods are not being called. Here’s what I have:

[TrackBindingType(typeof(MyComponent))]
public sealed class CustomMarkerTrack : MarkerTrack
{
    public IEnumerable<CustomMarker> CustomMarkers => GetMarkers().OfType<CustomMarker>();

    public override IEnumerable<PlayableBinding> outputs
    {
        get
        {
            // This is called as expected.
            Debug.Log(nameof(this.outputs), this);
            return base.outputs;
        }
    }
    protected override void OnBeforeTrackSerialize()
    {
        // This is called as expected.
        Debug.Log(nameof(OnBeforeTrackSerialize), this);
        base.OnBeforeTrackSerialize();
    }

    protected override void OnAfterTrackDeserialize()
    {
        // This is called as expected.
        Debug.Log(nameof(OnAfterTrackDeserialize), this);
        base.OnAfterTrackDeserialize();
    }

    protected override void OnCreateClip(TimelineClip clip)
    {
        // This is never called.
        Debug.Log(nameof(OnCreateClip), this);
        base.OnCreateClip(clip);
    }

    protected override Playable CreatePlayable(PlayableGraph graph, GameObject gameObject, TimelineClip clip)
    {
        // This is never called.
        Debug.Log(nameof(CreatePlayable), this);
        return base.CreatePlayable(graph, gameObject, clip);
    }


    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        // This is never called.
        Debug.Log(nameof(CreateTrackMixer), this);
        return ScriptPlayable<CustomMarkerMixer>.Create(graph, inputCount);
    }
}

What am I doing wrong?

Marker tracks don’t contain clips, so the three methods that aren’t being called aren’t expected to. They are intended to contain only markers.

If you want a track that contain clips and markers, you can simply inherit from TrackAsset.

I do not. I only want to override PrepareFrame on a marker-only track. How can I do this?

There is no callback or override to do that. A marker track generates a single built-in playable that handles firing the notification.

The mixer isn’t created unless there are clips or animated track parameters.

1 Like

Okay, thank you.

It sounds like I can get around it by creating a dummy playable clip and then calling GetMarkers?

I would very much like to see a callback added to marker-only tracks. For context, my use case is to trigger frame-perfect collisions in a fighting game. So the Notification pipeline’s queue-based LateUpdate approach isn’t quite reliable enough, and in addition I need to be able to Evaluate the graph manually in both Play and Edit modes (not just for reliable linear playback, but also for arbitrarily saving and loading game state for Rollback netplay).

Other than these limitations, markers are perfect for me because they provide a complete editor UI for adding, dragging, and setting the frame number of custom keyframes.

EDIT: I think I worked out a better solution whereby markers are used to edit their underlying clips, but not actually inspected during runtime. This is still not preferable compared to a moddable MarkerTrack, but it should be good enough for my purposes.