TestAnimation.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine;
  2. using System.Collections;
  3. public class TestAnimation : MonoBehaviour {
  4. Animator mAnimator = null;
  5. // Use this for initialization
  6. void Start () {
  7. mAnimator = GetComponentInChildren<Animator>();
  8. }
  9. // Update is called once per frame
  10. void Update()
  11. {
  12. AnimatorStateInfo stateinfo = this.mAnimator.GetCurrentAnimatorStateInfo(0);
  13. if (stateinfo.IsName("Appear") && stateinfo.normalizedTime >= 1.0f)
  14. {
  15. mAnimator.Play("Miss");
  16. }
  17. }
  18. void OnGUI()
  19. {
  20. if (GUI.Button(new Rect(10, 10, 100, 50), "appear"))
  21. {
  22. mAnimator.Play("Appear");
  23. }
  24. if (GUI.Button(new Rect(10, 70, 100, 100), "Idle"))
  25. {
  26. mAnimator.Play("Diss");
  27. }
  28. if (GUI.Button(new Rect(10, 130, 100, 100), "Stop"))
  29. {
  30. mAnimator.speed = 0;
  31. }
  32. if (GUI.Button(new Rect(10, 190, 100, 100), "Continue"))
  33. {
  34. mAnimator.speed = 1;
  35. }
  36. }
  37. }