Search Unity

Getting a list of playing animation clips from an animator when using playablegraphs?

Discussion in 'Animation' started by apapineni_unity, Apr 10, 2020.

  1. apapineni_unity

    apapineni_unity

    Joined:
    Aug 6, 2019
    Posts:
    4
    I'm currently building an animation system using playable graphs and I'd like to figure out which clips are playing on on object.

    My first thought would be to get the playable graph for the object, and then iterate through it to find the clipplayables that are currently playing.

    But there doesn't seem to be a way to get the playable graph from the animator after you've bound it. Animator.playableGraph returns null, and there doesn't seem to be any other way to get it.

    Is there any other method I could use to get playing clips using just a reference to the animator?
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Not that I know of, but you could keep the graphs you create in a Dictionary<Animator, PlayableGraph>.

    Or if you don't already have a component attached to the same GameObject to manage your graph, create one which you add in the editor only so that it can just hold the graph reference for you.

    But you should probably have a component like that as part of your system at runtime anyway because you need to destroy the graph when the object is destroyed.