Hello all
I’m getting starting with Timeline, the new feature of Unity, and it’s working like a charm!
I’m trying to detect the end of a timeline. So far, I found this :
_director = transform.GetComponentInChildren<PlayableDirector>();
And this in a coroutine :
if (_director.playableGraph.IsDone())
{
OnEnd();
}
Actually, it’s not working… (Object reference not set to an instance)
I’m looking for a more reliable way to do this. Do you know if there’s any events? Maybe this? But I don’t know how to get the PlayableBehaviour instance from the PlayableDirector.
Thanks a lot for your help!
[EDIT]
I found this way but I’m still not fully satisfied :
public IEnumerator CheckEnd()
{
while (Math.Abs(_director.duration - _director.time) > 0.2)
{ yield return new WaitForEndOfFrame(); }
OnEnd();
}
public void OnEnd()
{
Debug.Log("On end");
}