Animation animation = gameObject.GetComponent(); AnimationClip clip = new AnimationClip(); clip.name = "MyClip"; animation.AddClip(clip, clip.name);
Animation animation = GetComponentThis example demonstrates how to load an animation clip from a resources folder and play it. The "MyClip" animation clip is loaded and then added to the animation component. Finally, the animation is played using the Play method. The package library used for this method is the UnityEngine.Animation namespace.(); AnimationClip clip = Resources.Load ("MyClip"); animation.AddClip(clip, "MyClip"); animation.Play("MyClip");