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.
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
@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?