CrossHairOutBoundChecker.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class CrossHairOutBoundChecker : MonoBehaviour
  6. {
  7. [SerializeField] GameObject outTip;
  8. string[] tips = null;
  9. int tipIndex = -1;
  10. void Start() {
  11. tips = new string[]{
  12. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_0"),
  13. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_1"),
  14. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_2"),
  15. TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_3"),
  16. };
  17. }
  18. void Update()
  19. {
  20. int newTipIndex = -1;
  21. if (BowCamera.ins && BowCamera.ins.bowCameraFixed != null) {
  22. newTipIndex = BowCamera.ins.bowCameraFixed.outBoundIndex;
  23. }
  24. if (newTipIndex != tipIndex) {
  25. tipIndex = newTipIndex;
  26. if (tipIndex >= 0) {
  27. outTip.GetComponent<Text>().text = tips[tipIndex];
  28. }
  29. }
  30. if (newTipIndex >= 0) {
  31. if (!outTip.activeSelf) outTip.SetActive(true);
  32. } else {
  33. if (outTip.activeSelf) outTip.SetActive(false);
  34. }
  35. }
  36. }