Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Access to animator clip info when Timeline populates it

Discussion in 'Timeline' started by SuppleTeets, May 9, 2018.

  1. SuppleTeets

    SuppleTeets

    Joined:
    Aug 22, 2014
    Posts:
    30
    Hi, I have a script that checks which animation is playing and takes action accordingly. If I use Timeline to play animation clips on the Animator I can't find a way to check which animation is currently playing. Is there any way to find out?

    Tried it with or without an animator controller plugged in.
    animator.GetCurrentAnimatorClipInfo() returns nothing.

    The clip count rises in the animator's inspector gui, but I can't seem to find the info I need.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    I don't think the information is available through the animator, most of the public methods refer to the controller. The clip count you see is looking at data not in the public API.

    I think it's a bit of an oversight, there isn't really a way in the animator API to know that a timeline is playing on it. Definitely something we should correct.

    Unfortunately the only thing I can think is search the playable directors for that animator in the bindings and dig through the playableGraph/timeline to find the currently active clip. Not very friendly or efficient.
     
  3. SuppleTeets

    SuppleTeets

    Joined:
    Aug 22, 2014
    Posts:
    30
    Ah okay, dang that's what I was afraid of. Thanks for the heads up.