Search Unity

Is it possible to get clip START and DURATION from timeline

Discussion in 'Timeline' started by sabther, Oct 4, 2018.

  1. sabther

    sabther

    Joined:
    Sep 5, 2018
    Posts:
    21
    Hello

    I am thinking, is it possible to get clip START and DURATION from timeline after the start();

    Which means the version for the playable graph.

    In this case the virtual camera clip, The priorities as I highlighted in the picture.




    Thanks!
     
  2. sabther

    sabther

    Joined:
    Sep 5, 2018
    Posts:
    21
    Need some help here, anyone?
     
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The clip information is available in the TimelineClip. For example:

    Code (CSharp):
    1. var timeline = playableDirector.playableAsset as TimelineAsset;
    2. foreach (var track in timeline.GetOutputTracks())
    3. {
    4.      foreach (var clip in track.GetClips())
    5.           Debug.Log(clip.start);
    6.  
    7. }
    The cinemachine information is available on the component, which can be retrieved from the clip/playable director as follows.

    Code (CSharp):
    1. var shot = clip.asset as CinemachineShot;
    2. bool valid = false;
    3. var component = playableDirector.GetReferenceValue(
    4.       shot.VirtualCamera.exposedName, out valid) as CinemachineVirtualCameraBase;
     
  4. sabther

    sabther

    Joined:
    Sep 5, 2018
    Posts:
    21
    thank you seant

    Also is it possible to know the current frame on the timeline during runtime?

    As a test the game in the unity engine(not the compiled game) I can see the progress marker moving on the timeline.

    Can I get the script to also know what the current frame is? 屏幕快照 2018-10-05 下午9.39.45.png

    thank you very much!
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The current time is available on the playable director (PlayableDirector.time). You need to convert it to frames, as the playable system use frames during playback.

    The frame rate can be found on the asset at TimelineAsset.editorSettings.fps.