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[]{ "瞄准方向已超出视野范围,请将弓往右移动!", "瞄准方向已超出视野范围,请将弓往左移动!", "瞄准方向已超出视野范围,请将弓往下移动!", "瞄准方向已超出视野范围,请将弓往上移动!", }; } 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); } } }