CrossHairOutBoundChecker.cs 1.6 KB

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