Search Unity

How to access custom markers via script?

Discussion in 'Timeline' started by volvis, Dec 3, 2019.

  1. volvis

    volvis

    Joined:
    Jan 10, 2013
    Posts:
    11
    I want to specify certain times in timeline via markers and read out their positions.

    Consider custom markers like this:

    public class MidPointMarker : UnityEngine.Timeline.Marker {}


    How do I find all MidPointMarkers and their times set within the PlayableAsset?
     
  2. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    If your marker is placed on a track, you can get all markers on this track with GetMarkers(). You can filter the results to get only MidPointMarkers.

    If your marker is placed on the timeline itself, you'll have to get the marker track from the timeline and call GetMarkers() afterwards.

    Finally, if you want all MidPointMarkers inside a timeline, you can iterate on all tracks and call GetMarkers() on each one.

    Hope this helps!