Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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:
    69
    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:
    644
    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.