AnimaUI.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AnimaUI : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. public Animator animaui;
  8. public BoxCollider[] buttonBoxmanage;
  9. private float time = 0;
  10. bool IsExit = true;
  11. void Start()
  12. {
  13. animaui = this.gameObject.GetComponent<Animator>();
  14. for (int i = 0; i < buttonBoxmanage.Length; i++)
  15. {
  16. buttonBoxmanage[i].gameObject.SetActive(false);
  17. }
  18. animaui.speed = 0;
  19. }
  20. // Update is called once per frame
  21. void Update()
  22. {
  23. if (IsExit == false)
  24. {
  25. time += Time.deltaTime;
  26. if (time >= 3)
  27. {
  28. StartCoroutine(ButtonMg(false));
  29. animaui.SetBool("UIAnima", true);
  30. time = 0;
  31. for (int i = 0; i < buttonBoxmanage.Length; i++)
  32. {
  33. buttonBoxmanage[i].enabled = false;
  34. }
  35. IsExit = true;
  36. }
  37. // Debug.Log(time + "时长");
  38. }
  39. }
  40. /// <summary>
  41. /// UI按钮管理
  42. /// </summary>
  43. public IEnumerator ButtonMg(bool isOpen)
  44. {
  45. yield return new WaitForSeconds(0.7f);
  46. buttonBoxmanage[0].gameObject.SetActive(isOpen);
  47. buttonBoxmanage[1].gameObject.SetActive(isOpen);
  48. buttonBoxmanage[2].gameObject.SetActive(isOpen);
  49. }
  50. public void StartButton()
  51. {
  52. IsExit = true;
  53. time = 0;
  54. animaui.speed = 1;
  55. animaui.SetBool("UIAnima", false);
  56. for (int i = 0; i < buttonBoxmanage.Length; i++)
  57. {
  58. buttonBoxmanage[i].gameObject.SetActive(true);
  59. }
  60. Invoke("Boxmg", 1f);
  61. }
  62. public void Boxmg()
  63. {
  64. for (int i = 0; i < buttonBoxmanage.Length; i++)
  65. {
  66. buttonBoxmanage[i].enabled = true;
  67. }
  68. }
  69. public void RayPointenter()
  70. {
  71. IsExit = true;
  72. time = 0;
  73. }
  74. /// <summary>
  75. ///
  76. /// </summary>
  77. public void RayPointexit()
  78. {
  79. IsExit = false;
  80. }
  81. }