Search Unity

How to check if Timeline Editor is scrubbing.

Discussion in 'Timeline' started by tarahugger, Dec 19, 2018.

  1. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    I have a need to know when the user is dragging the time on a timeline in editor play mode, because for the animation to display as intended there are some changes that need to be made in the scene (Disable Gravity/Collider/NavMeshAgent).

    I am able to check for the Scrub Manipulator in the editor window state with reflection. Is there an easier/cleaner/intended way and if not is it something that could be considered to add in the future?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Hmm... typically this is passed to custom playables, but to query that externally...the closest I can think of is something like:

    Code (CSharp):
    1. // the instance is active, but not playing and the time has changed
    2. var playableDirector = TimelineEditor.inspectedDirector;
    3. var isScrub = playableDirector.playableGraph.IsValid() && !playableDirector.playableGraph.IsPlaying() && lastTime != playableDirector.time;
    4. lastTime = playableDirector.time;
     
    tarahugger likes this.