Return the name of the animation clip playing

Hi, is there any way to return the currently playing animation clip, aside from creating a function which iterates through all the clips and testing each using animation.IsPlaying?

Cheers

animation.clip.name;

As of today it has been difficult for me to find conclusive information on this topic, so I’ll try to help here:

With legacy animations, the playing clip name cannot be obtained. Indeed you have to iterate through all the clips and ask if they are playing or not.

I’ll put here a simple tool and code sample. Is enough to attach it as a component to the same GameObject that has the Animation.

using UnityEngine;

public class inspector_animacion : MonoBehaviour
{
#if UNITY_EDITOR

	Animation anim;

	public string normalized_times;
    [TextArea]
    public string animaciones_en_play;
	[Space]
	public float time_scale = 0.3f;
	public bool aplicar_time_scale;

	void Start()
    {
		anim = GetComponent<Animation>();
	}

    void Update()
    {
		Time.timeScale = (aplicar_time_scale ? time_scale : 1);

		normalized_times = animaciones_en_play = "";

		foreach (AnimationState state in anim)
	        if(state.enabled)
            {
				normalized_times += state.normalizedTime + "  ";
				animaciones_en_play += state.name + "

";
}
}

    #endif
    }