[C#] Using .anim file

I’m a beginner so please be nice :slight_smile:

My problem: I created an animation file (.anim file) with Unity, but I came across several problems shortly after and couldn’t find a solution on the internet. And the unity page for Animation.Play wasn’t very useful (I don’t get it).

I can use it via drag and drop on my sprite, but it will start automatically (can’t seem to find the automatic start box on the inspector). I want to write a C# script so the animation will only play if my mouse is on it.

Something like this:

public class dialog_button : MonoBehaviour 
{
	
	void OnMouseEnter() 
	{
		//play animation
	}
}

.
I hope someone could help me

The animation properties are usually found on the import fbx settings.