Browse Source

边界提示

lvjincheng 3 years ago
parent
commit
157206295a

+ 1 - 1
Assets/BowArrow/Scripts/Game/BowCamera.cs

@@ -212,7 +212,7 @@ public class BowCamera : MonoBehaviour
         }
     }
 
-    BowCameraFixed bowCameraFixed = null;
+    public BowCameraFixed bowCameraFixed = null;
     public class BowCameraFixed {
         public GameObject gameObject;
         public Transform transform;

+ 2 - 1
Assets/BowArrow/Scripts/Game/CrossHair.cs

@@ -67,7 +67,7 @@ public class CrossHair : MonoBehaviour
 
     #region 固定相机更新
         RectTransform _parentRTF;
-        public RectTransform parentRTF {
+        RectTransform parentRTF {
             get {
                 if (!_parentRTF) {
                     _parentRTF = transform.parent.GetComponent<RectTransform>();
@@ -78,6 +78,7 @@ public class CrossHair : MonoBehaviour
         Vector3 centerPoint = new Vector3(0.5f, 0.5f, 0);
         Vector3 targetPosition;
         public void UpdatePostionWhenFixedCamera() {
+            if (!visiable) return;
             Transform transform = BowCamera.ins.transform;
             Ray ray = new Ray(transform.position, transform.forward);
             RaycastHit hitInfo;

+ 3 - 11
Assets/BowArrow/Scripts/Game/CrossHairOutBoundChecker.cs

@@ -16,18 +16,10 @@ public class CrossHairOutBoundChecker : MonoBehaviour
 
     void Update()
     {
-        Rect pr = CrossHair.ins.parentRTF.rect;
-        Vector3 lp = CrossHair.ins.transform.localPosition;
         int newTipIndex = -1;
-        if (lp.x < -pr.width / 2) {
-            newTipIndex = 0;
-        } else if (lp.x > pr.width / 2) {
-            newTipIndex = 1;
-        } else if (lp.y > pr.height / 2) {
-            newTipIndex = 2;
-        } else if (lp.y < -pr.height / 2) {
-            newTipIndex = 3;
-        } 
+        if (BowCamera.ins && BowCamera.ins.bowCameraFixed != null) {
+            newTipIndex = BowCamera.ins.bowCameraFixed.outBoundIndex;
+        }
         if (newTipIndex != tipIndex) {
             tipIndex = newTipIndex;
             if (tipIndex >= 0) {