using UnityEngine; using System.Collections; public class TestAnimation : MonoBehaviour { Animator mAnimator = null; // Use this for initialization void Start () { mAnimator = GetComponentInChildren(); } // Update is called once per frame void Update() { AnimatorStateInfo stateinfo = this.mAnimator.GetCurrentAnimatorStateInfo(0); if (stateinfo.IsName("Appear") && stateinfo.normalizedTime >= 1.0f) { mAnimator.Play("Miss"); } } void OnGUI() { if (GUI.Button(new Rect(10, 10, 100, 50), "appear")) { mAnimator.Play("Appear"); } if (GUI.Button(new Rect(10, 70, 100, 100), "Idle")) { mAnimator.Play("Diss"); } if (GUI.Button(new Rect(10, 130, 100, 100), "Stop")) { mAnimator.speed = 0; } if (GUI.Button(new Rect(10, 190, 100, 100), "Continue")) { mAnimator.speed = 1; } } }