Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Get the Animation Clip Of An Animator State and Rename The State To the Name of the Clip

Discussion in 'Scripting' started by billygamesinc, Nov 14, 2022.

  1. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    364
    I've been doing this manually myself so I was wondering if it's possible to automate this.

    Loop through all the animations OR animation clips of an Animator and rename the state to it's clip.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,357
    There's probably a way to access that through editor scripting. What have you found in the docs so far?
     
  3. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    364
    Nothing at the moment in regards to getting the state of an animation or the animation of a state. I've only found ways to get their info individually.
     
  4. akoolud

    akoolud

    Joined:
    Apr 19, 2023
    Posts:
    6
    code for inside an editor script
    Code (CSharp):
    1.   AnimatorController animController = animator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
    2.         foreach (var s in animController.layers[0].stateMachine.states)
    3.         {
    4.             s.state.name = s.state.motion.name;
    5.         }
     
  5. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    364
    Thanks. Does this just capture a single pose or the whole sequence and how does one export this?