HeadBtnManager.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using Blue;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.Events;
  6. using UnityEngine.UI;
  7. public class HeadBtnManager : MonoSingleton<HeadBtnManager>, IController
  8. {
  9. /*
  10. * 1. 当1级页面消失后 ,在这连显示 重置按钮 和主界面
  11. * 2. 点击重置按钮的时候,当前UI消失,将1级页面显示出来
  12. * 3. 返回Home页面的时候 当前UI消失,并且关闭1级页面
  13. *
  14. * 存储各类重置按钮
  15. */
  16. public Button homeBtn;
  17. public Button dhBtn;
  18. public Button rtcBtn;
  19. public Button homeBtn2;
  20. public Toggle hideBtn;
  21. // public Button
  22. public UIFollow uiFollow;
  23. private Transform player;
  24. private IQueueSystem mQueueSystem;
  25. public ScenesManager.SceneType type;
  26. private void Start()
  27. {
  28. dhBtn.onClick.AddListener(() =>
  29. {
  30. Hide();
  31. if (uiFollow != null)
  32. uiFollow.Show(transform.position);
  33. });
  34. rtcBtn.onClick.AddListener(() =>
  35. {
  36. Hide();
  37. if (uiFollow != null)
  38. uiFollow.Show(rtcBtn.transform.position);
  39. });
  40. player = new GameObject("Player").transform;
  41. Hide();
  42. mQueueSystem = this.GetService<IQueueSystem>();
  43. hideBtn.onValueChanged.AddListener((state) =>
  44. {
  45. HideL3(state);
  46. });
  47. homeBtn.onClick.AddListener(GoHome);
  48. homeBtn2.onClick.AddListener(GoHome);
  49. }
  50. public UnityEvent OnReset = new UnityEvent();
  51. private void Update()
  52. {
  53. OnReset?.Invoke();
  54. /*
  55. player.position =OpenXRCamera.Instance.head.transform.position;
  56. player.eulerAngles = new Vector3(0,OpenXRCamera.Instance.head.transform.eulerAngles.y, 0);
  57. transform.position = OpenXRCamera.Instance.head.position + player.transform.forward * 1.5f + new Vector3(0f, 0f, 0.1f);
  58. transform.eulerAngles = player.eulerAngles;
  59. */
  60. }
  61. public void ShowResetBtn(ScenesManager.SceneType type , UIFollow uiFollow)
  62. {
  63. this.type = type;
  64. this.uiFollow = uiFollow;
  65. switch (type)
  66. {
  67. case ScenesManager.SceneType.GameStartLogo:
  68. break;
  69. case ScenesManager.SceneType.ShowLogin:
  70. break;
  71. case ScenesManager.SceneType.ShowChoose:
  72. break;
  73. case ScenesManager.SceneType.ShowXunJian:
  74. break;
  75. case ScenesManager.SceneType.ShowXJ:
  76. break;
  77. case ScenesManager.SceneType.ShowDH:
  78. homeBtn.gameObject.SetActive(true);
  79. dhBtn.gameObject.SetActive(true);
  80. break;
  81. case ScenesManager.SceneType.ShowRTC:
  82. rtcBtn.gameObject.SetActive(true);
  83. break;
  84. case ScenesManager.SceneType.ShowRTCHistory:
  85. rtcBtn.gameObject.SetActive(true);
  86. homeBtn2.gameObject.SetActive(true);
  87. break;
  88. case ScenesManager.SceneType.ShowDevice:
  89. break;
  90. case ScenesManager.SceneType.ShowBasicDevice:
  91. break;
  92. default:
  93. break;
  94. }
  95. }
  96. private void Hide()
  97. {
  98. homeBtn.gameObject.SetActive(false);
  99. dhBtn.gameObject.SetActive(false);
  100. rtcBtn.gameObject.SetActive(false);
  101. homeBtn2.gameObject.SetActive(false);
  102. }
  103. public void HideL3( bool on)
  104. {
  105. foreach (var go in mQueueSystem.Level3List)
  106. {
  107. go.SetActive(!on);
  108. }
  109. }
  110. public void GoHome()
  111. {
  112. Debug.LogError("GoHome");
  113. if(BladeServerManager.Instance.foundItem!=null)
  114. BladeServerManager.Instance.foundItem.gameObject.SetActive(false);
  115. if(ShowDeviceControle.Instance!=null && ShowDeviceControle.Instance.DeviceDetailsControl!=null)
  116. ShowDeviceControle.Instance.DeviceDetailsControl.gameObject.SetActive(false);
  117. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  118. BladeServerManager.Instance.isDaoHang = false;
  119. WayFindingManager.Instance.CloseWayFind();
  120. this.uiFollow = null;
  121. Hide();
  122. }
  123. }