Is it possible to build timeline at runtime?

I want to create custom timeline based on data I get at runtime so I cant really use prebuild playable. Basically create timeline with track witch length can be set at runtime. It would mostly use activation tracks.

I would also be very interested in this, I have been trying it for days now!

In the end I scraped the timeline completely because, as I said I mostly needed activation track functionality. What I ended up doing was: I created simple coroutine that turns objects of and on and places them one after another. Every object has length that represents how long it is active and delay parameter that tells the coroutine how log it should wait until it activates another object. I don't know if this is helpful in your case but that is how I resolve it hope it helps.

Has anyone found an answer to this?

Timelines are basically just Playables on a graph. You can modify or construct that graph how you want at runtime using the Playables API.

For example, if you get your PlayableDirector component from the object, then you can get access to the Timeline of it by TimelineAsset timeline = playableDirector.playableAsset as TimelineAsset;.

Now you can modify the Timeline however you want, such as calling timeline.CreateTrack() or DeleteTrack(). You can get the tracks currently on it with var tracks = timeline.GetOutputTracks() as List<TrackAsset>; (and GetRootTracks() to include tracks that don't have a target assignment) and iterate through to find Sequences tracks for example to then get sub-timelines (sequences).

To modify timings, when you have reference to a TrackAsset, you can call trackAsset.GetClips() to get the clips of that track on the timeline. And from there, clips have properties such as clip.clipIn which is where on the track the clip should start, and clip.duration , which will give you the end point of the clip by doing clip.clipIn + clip.duration. These properties can be set to customize it how you want.

Some tracks have bindings for what they operate on, in which case you can set that by doing playableDirector.SetGenericBinding(trackReference, objectToAssign)

So from here you should get a sense of what to do to construct Timelines at runtime.