using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /* 检测器-检测游戏射击准心是否出屏幕边界 */ public class CrossHairOutBoundChecker : MonoBehaviour { [SerializeField] GameObject outTip; string[] tips = null; int tipIndex = -1; void Start() { tips = new string[]{ TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_0"), TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_1"), TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_2"), TextAutoLanguage2.GetTextByKey("game_crosshair_outbound_3"), }; } void Update() { int newTipIndex = -1; if (BowCamera.ins && BowCamera.ins.bowCameraFixed != null) { newTipIndex = BowCamera.ins.bowCameraFixed.outBoundIndex; } if (newTipIndex != tipIndex) { tipIndex = newTipIndex; if (tipIndex >= 0) { outTip.GetComponent().text = tips[tipIndex]; } } if (newTipIndex >= 0) { if (!outTip.activeSelf) outTip.SetActive(true); } else { if (outTip.activeSelf) outTip.SetActive(false); } } }