Search Unity

Jump to Frame

Discussion in 'Timeline' started by hiroaoki, Oct 18, 2017.

  1. hiroaoki

    hiroaoki

    Joined:
    Dec 12, 2015
    Posts:
    2
    Can I jump to any frame while I play the timeline?
     
  2. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    Yes. You can set the time on the PlayableDirector component: Director.time
     
    FurySven and hiroaoki like this.
  3. hiroaoki

    hiroaoki

    Joined:
    Dec 12, 2015
    Posts:
    2
    Thanks, julienne !
     
  4. Rodolinc

    Rodolinc

    Joined:
    Sep 23, 2013
    Posts:
    63
    Sorry to bump this, why there's no "frame" property exposed apart from time? if in the timelline editor window we see only frames displayed?
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The engine has no real concept of 'frames', at least in the timeline sense. The frames in the timeline editor is simply for authoring purposes, but during playback, the timeline is most often evaluated between frames. Because timeline is updated after Update() in the player loop, the delta time can vary, just like any other script.

    However, you can do a frame->time conversion yourself with
    director.time = frame / ((TimelineAsset) director.playableAsset).editorSettings.fps;
     
    NatCou and khaled24 like this.
  6. NatCou

    NatCou

    Joined:
    Jan 29, 2017
    Posts:
    26
    Code (CSharp):
    1.   private void setTime()
    2.     {
    3.        playableDirector = myPlayableDirectorGO.GetComponent<PlayableDirector>();
    4.         Debug.Log(timeLinePosition);
    5.         playableDirector.time = timeLinePosition / ((TimelineAsset)playableDirector.playableAsset).editorSettings.fps;
    6.         playableDirector.RebuildGraph();
    7.         playableDirector.Play();
    8.         //playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0);
    9.     }