CrossHairOutBoundChecker.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /* 检测器-检测游戏射击准心是否出屏幕边界 */
  6. public class CrossHairOutBoundChecker : MonoBehaviour
  7. {
  8. [SerializeField] GameObject outTip;
  9. string[] tips = null;
  10. int tipIndex = -1;
  11. void Start() {
  12. tips = new string[]{
  13. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_0"),
  14. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_1"),
  15. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_2"),
  16. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_3"),
  17. };
  18. if (BluetoothAim.ins && (BluetoothAim.ins.isMainConnectToInfraredDevice() || BluetoothAim.ins.isMainConnectToGun()))
  19. {
  20. //当使用HOUYI Pro和枪这种红外定位方案的连接时,需在游戏中,将“瞄准方向已超出视野范围,请将弓往左移动”这种提示语去掉
  21. gameObject.SetActive(false);
  22. }
  23. }
  24. void Update()
  25. {
  26. int newTipIndex = -1;
  27. if (BowCamera.ins && BowCamera.ins.bowCameraFixed != null) {
  28. newTipIndex = BowCamera.ins.bowCameraFixed.outBoundIndex;
  29. }
  30. if (newTipIndex != tipIndex) {
  31. tipIndex = newTipIndex;
  32. if (tipIndex >= 0) {
  33. outTip.GetComponent<Text>().text = tips[tipIndex];
  34. }
  35. }
  36. if (newTipIndex >= 0) {
  37. if (!outTip.activeSelf) outTip.SetActive(true);
  38. } else {
  39. if (outTip.activeSelf) outTip.SetActive(false);
  40. }
  41. }
  42. }