CrossHairOutBoundChecker.cs 545 B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CrossHairOutBoundChecker : MonoBehaviour
  5. {
  6. [SerializeField] GameObject outTip;
  7. void Update()
  8. {
  9. Rect pr = CrossHair.ins.parentRTF.rect;
  10. Vector3 lp = CrossHair.ins.transform.localPosition;
  11. if (Mathf.Abs(lp.x) > pr.width / 2 || Mathf.Abs(lp.y) > pr.height / 2) {
  12. if (!outTip.activeSelf) outTip.SetActive(true);
  13. } else {
  14. if (outTip.activeSelf) outTip.SetActive(false);
  15. }
  16. }
  17. }