How do I get Clip Timing (TimelineClip) info from PlayableAsset

I would like to tie Button’s Click Event to a PlayableAsset, which is simple enough, but I noticed that the event is fired for each instance of the Asset on the Playable Track.

So I was thinking if I had the PlayableAsset’s Start/End from the Clip Timing ( TimelineClip data) I could test against the current time of the Director to find which Playable asset I need.

I didn’t see any clear API for getting the TimelineClip data from an Asset.

Can you help?

I had a similar problem, and it doesn’t look like the playable asset has any knowledge of the TimelineClip. If you have a reference to the timeline asset itself, you can do something like:

var tracks = timeline.GetOutputTracks();
foreach (TrackAsset track in tracks)
{
    var clips = track.GetClips();
    foreach (TimelineClip clip in clips)
    {
        if (clip.asset == targetAsset) return clip;
    }
}

and then read the timing from clip.start and clip.end

3 Likes

pass start and end while build playable

1 Like

@dimmduh1 's answer is the proper one as far as getting the information in your playable: you should inject that information in your playable when your create the playable.

But I’m curious, can you tell me why you want to associate a button to a playable asset, and why it must be different based on time?

it’s not my code above.

But I’m writing basic classes to easy create custom timeline tracks
https://gist.github.com/dimmduh/033acb2dad9f9b4a6532534a2fe0a189