Search Unity

Is there a way get all states/clips from animator

Discussion in 'Animation' started by Wonderment_by_Design, Sep 17, 2019.

  1. Wonderment_by_Design

    Wonderment_by_Design

    Joined:
    Oct 23, 2017
    Posts:
    4
    I'm trying to get all the states from an animator so I can create UI buttons dynamically for every state in an animator. But can't seem to find a way to do it. I found that you can get the current state but not all.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    You can't.

    You can access the animator.runtimeAnimatorController.animationClips, but that's just the clips, not the states.

    If you want better animation scripting, you might be interested in Animancer (link in my signature). If for example you want to just have a list of animations which you can iterate through to create a play button for each of them, then Animancer would let you do exactly that - make an array or list of AnimationClips and then play them when needed, without wasting time setting up Animator Controllers.
     
    Wonderment_by_Design likes this.