[Sequences] start, end, duration of timeline sequences

I need to access the 'start, end, duration' info from one of my "Shot Sequences" which are in turn "children" of the Master sequence. How can I reference their data - and or manipulate it from C#.


Hello! On the "TimelineSequence" object you can access those information and change them in C#. If you provide a bit more context on your use case I can help you with code examples if needed!

1 Like

[quote=“ellka”, post:2, topic: 865202]
Hello! On the “TimelineSequence” object you can access those information and change them in C#. If you provide a bit more context on your use case I can help you with code examples if needed!

I’m am making an ui runtime timeline clone. Ideally I would reference the master sequence or sequence filter, and loop through the shot sequences that it contains - then placing ui images according to their start, end and duration.

In this example, I’ve added them manually to a _playableDirectors list as I’ve been experimenting with different ideas.

foreach (var child in _playableDirectors)
    float starttime = (float) child.initialTime;
    float duration = (float) child.duration;

    float endtime = starttime + duration;
    string name = child.name;
    float totalwidth = timelineParent.GetComponent<RectTransform>().rect.width;
    Debug.Log("name: " + name + "starttime: " + starttime + " endtime: " + endtime + " duration: " + duration +
              " totalwidth: " + totalwidth);

    Instantiate(shotIndicator, timelineParent).GetComponent<RectTransform>().anchoredPosition =
        new Vector2(starttime, 0);


It works with end-time and duration, but start-time is giving me a harder time…
//edit. I’m aware " new Vector2(starttime, 0);" wouldn’t work like that… :wink:

What kind of objects the _playableDirectors list contains?

[quote=“ellka”, post:4, topic: 865202]
What kind of objects the _playableDirectors list contains?
As of now, I’m using this.
public PlayableDirector[ ] _playableDirectors;

But it seems like I should be using some of the other classes/objects, honestly I’m a bit lost navigating the timeline jungle right now… Ideally I’d just open a public variable to get the master sequence or sequence filter and get the list of sub-sequences / shots through that.

If it is really on MasterSequence and sequences objects that you want to iterate on and display, then you can get MasterSequence assets via the AssetDatabase API. And from there iterate on children and start/end/duration values.

You could actually do it from Timeline as well. But it's not the PlayableDirector info that you need but the Timeline asset that is bind to it and its tracks and clips.

Using Sequences API (it's pseudo code, I didn't test it):

var masterSequence = AssetDatabase.LoadAssetAtPath<MasterSequence>("Assets/Sequences/MyMasterSequence.asset");

var rootSequence = masterSequence.rootSequence;
// Here you can already check rootSequence.start/end/duration

// Or loop over its children sequence:
foreach (var childSequence in rootSequence.children)
    var timelineSequence = childSequence as TimelineSequence;
    // Access timelineSequence.start/end/duration...
    // Or loop through its children again if you need....

Using timeline (again, I didn't test):

// Assuming you have a playable director in hand:
var timeline = playableDirector.playableAsset as TimelineAsset;

// Or, if you have a TimelineSequence object:
var timeline = myTimelineSequence.timeline;

// Or, you can even get a TimelineAsset directly from the AssetDatabase like I did above to retrieve a MasterSequence:
var timeline = AssetDatabase.LoadAssetAtPath<TimelineAsset>("Assets/myTimelineAsset.playable");

foreach (var track in timeline.GetOutputTracks())
    if (!track is EditorialTrack)

    foreach (var clip in track.GetClips())
        // Here get clip.start/end/duration;

I don't know if it help having those examples... but I hope.
Maybe it will help providing more precise questions if you have some. Don't hesitate!

Thank you so much Elka! This works like a charm.
As a side note, we're very excited about the Sequences workflow and your efforts with it. I hope you're still actively developing it and have more examples and doc content in the pipeline. As mentioned, we're working to enable some runtime editing, creation and manipulation of sequences - examples or articles exploring that sort of usecase is super interesting. :)

1 Like

I'm happy that helped!

We are still actively developing it yes, no worries!
And we are happy to get your feedback! It's actually interesting to know your runtime usage, I think it is the first time we have such use case (most users are editor only, at least to build their editorial with Sequences). I hope you'll find what you need!