Is there a way to replace animation clip in AnimatorController in editor ?

Hi there

According to such as this topic in doc :

I can’t find any way to get or set animation clip in class which named AnimatorState.

In other words , Is the only way to replace clip in controller that used Override Animator Controller ?


HI @HahnSC . If you want to change animations in animatorState during runtime you need to use Animator Override Controller. Here is a simple code with changing animation in animator states

Animator anim = gameObject.GetConponent<Animator>();
AnimatorOverrideController aoc = new AnimatorOverrideController(anim.runtimeAnimatorController);
var anims = new List<KeyValuePair<AnimationClip, AnimationClip>>();

anims.Add(new KeyValuePair<AnimationClip, AnimationClip>(AnimationClipInAnimator, NewAnimationClip)));

 anim.runtimeAnimatorController = aoc;