Cannot get clip length for ControlTrack controlled MonoBehaviour (through ITimeControl)

Hi guys,

timeline looks very nice so far but I am somewhat lost when it comes to scripting it.
Scenario: I have a MonoBehaviour that is controlled via ITimeControl and a Control Track. The “SetTime(double time)” function gets called as expected but it only provides me with the absolute time inside my ControlPlayableAsset Clip.
Is there any way to get some more information into my MonoBehaviour, like duration of the clip?

I want to use the ControlTrack to blend between some values, so I would need either a normalized time or some way to normalize it, i.e. the duration of the clip.

Any ideas?

Thanks,
Sebastian

Ok,
I figured out a possible solution:
The key to success was to add an ExposedReference pointing to the target object into the PlayableAsset. See code below.

    [System.Serializable]
    public class TimeControlAsset : PlayableAsset,  ITimelineClipAsset
    {
        public bool controlActivation;
        public ExposedReference<GameObject> target;

        public override Playable CreatePlayable (PlayableGraph graph, GameObject go)
        {
            var playable = ScriptPlayable<TimeControlPlayableBehaviour>.Create (graph);
            playable.GetBehaviour().Target = target.Resolve(graph.GetResolver());

            return playable;
        }

        public ClipCaps clipCaps {
            get {
                return ClipCaps.None;
            }
        }
    }

This reference is passed to the PlayableBehaviour script.

  public class TimeControlPlayableBehaviour : PlayableBehaviour
    {
        [SerializeField] GameObject target;
        public GameObject Target {
            get {
                return target;
            }
            set {
                target = value;
            }
        }
        public override void OnGraphStart(Playable playable)
        {
        }

        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
        }

        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
        }

        public override void PrepareFrame(Playable playable, FrameData info)
        {
            if (target == null)
                return;

            var normalizedTime = playable.GetTime() / playable.GetDuration();
            target.GetComponent<SomeType>.SetNormalizedTime(normalizedTime);
            }
        }
    }

I still have problems understanding the structure of the whole timeline system. It is very convenient to use but the documentation is quite poor (or i don’t know where to look)

Cheers, case closed.
Sebastian