ResetView.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.EventSystems;
  6. using SC;
  7. public class ResetView : MonoBehaviour {
  8. [SerializeField]
  9. private UIButton ResetBtn;//重置场景的按钮
  10. [SerializeField]
  11. private UIButton OpenVufoiraBtn;//开启扫描
  12. [SerializeField]
  13. private UIButton CloseVufoiraBtn;//关闭扫描
  14. [SerializeField]
  15. private UIButton ExitBtn;//退出的按钮
  16. void Start () {
  17. ResetBtn.onClick.AddListener(ResetClickBtn);
  18. ExitBtn.onClick.AddListener(ExitClickBtn);
  19. ExitBtn.gameObject.SetActive(false);
  20. if (OpenVufoiraBtn!= null)
  21. OpenVufoiraBtn.onClick.AddListener(OpenVufoiraClick);
  22. if (CloseVufoiraBtn != null)
  23. {
  24. CloseVufoiraBtn.gameObject.SetActive(false);
  25. CloseVufoiraBtn.onClick.AddListener(CloseVufoiraClick);
  26. }
  27. if(OpenVufoiraBtn != null)
  28. OpenVufoiraBtn.gameObject.SetActive(false);
  29. if(CloseVufoiraBtn != null)
  30. CloseVufoiraBtn.gameObject.SetActive(false);
  31. MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间
  32. MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间
  33. }
  34. private void ShowEffect(System.Object data = null)
  35. {
  36. ExitBtn.gameObject.SetActive(true);
  37. }
  38. private void HideEffect(System.Object data = null)
  39. {
  40. ExitBtn.gameObject.SetActive(false);
  41. }
  42. private void OnDestroy()
  43. {
  44. ResetBtn.onClick.RemoveListener(ResetClickBtn);
  45. ExitBtn.onClick.RemoveListener(ExitClickBtn);
  46. if (OpenVufoiraBtn != null)
  47. OpenVufoiraBtn.onClick.RemoveListener(OpenVufoiraClick);
  48. if (CloseVufoiraBtn != null)
  49. {
  50. CloseVufoiraBtn.onClick.RemoveListener(CloseVufoiraClick);
  51. }
  52. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间
  53. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间
  54. }
  55. private void ResetClickBtn()
  56. {
  57. SvrPlugin.Instance.RecenterTracking();
  58. }
  59. private void ExitClickBtn()
  60. {
  61. #if UNITY_EDITOR
  62. UnityEditor.EditorApplication.isPlaying = false;
  63. #elif UNITY_IPHONE || UNITY_ANDROID
  64. Application.Quit();
  65. #endif
  66. }
  67. private void OpenVufoiraClick()
  68. {
  69. CloseVufoiraBtn.gameObject.SetActive(true);
  70. OpenVufoiraBtn.gameObject.SetActive(false);
  71. CDebug.Log("开启扫描识别的点击");
  72. MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SEND_CHANGE_TRACK_IMAGE, true);
  73. }
  74. private void CloseVufoiraClick()
  75. {
  76. CloseVufoiraBtn.gameObject.SetActive(false);
  77. OpenVufoiraBtn.gameObject.SetActive(true);
  78. CDebug.Log("关闭扫描识别的点击");
  79. MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SEND_CHANGE_TRACK_IMAGE, false);
  80. }
  81. }