lvjincheng 4 лет назад
Родитель
Сommit
82d32007bd

+ 8 - 8
Assets/BowArrow/Scenes/Game.unity

@@ -7460,7 +7460,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 29.245823, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &589339043
@@ -9775,9 +9775,9 @@ RectTransform:
   m_Father: {fileID: 1349314726}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 10, y: -16.5}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 29.245823, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &694545845
@@ -15760,7 +15760,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 29.245823, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1218454288
@@ -17635,7 +17635,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 48.491646, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1338115114
@@ -22406,7 +22406,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
-  m_RaycastTarget: 1
+  m_RaycastTarget: 0
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
   m_OnCullStateChanged:
@@ -25599,7 +25599,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 78.491646, y: 0}
   m_SizeDelta: {x: 0, y: 40}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1845023679

+ 25 - 1
Assets/BowArrow/Scripts/Game/CrossHairOutBoundChecker.cs

@@ -1,16 +1,40 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.UI;
 
 public class CrossHairOutBoundChecker : MonoBehaviour
 {
     [SerializeField] GameObject outTip;
+    string[] tips = {
+        "瞄准方向已超出视野范围,请将弓往右移动!",
+        "瞄准方向已超出视野范围,请将弓往左移动!",
+        "瞄准方向已超出视野范围,请将弓往下移动!",
+        "瞄准方向已超出视野范围,请将弓往上移动!",
+    };
+    int tipIndex = -1;
 
     void Update()
     {
         Rect pr = CrossHair.ins.parentRTF.rect;
         Vector3 lp = CrossHair.ins.transform.localPosition;
-        if (Mathf.Abs(lp.x) > pr.width / 2 || Mathf.Abs(lp.y) > pr.height / 2) {
+        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 (newTipIndex != tipIndex) {
+            tipIndex = newTipIndex;
+            if (tipIndex >= 0) {
+                outTip.GetComponent<Text>().text = tips[tipIndex];
+            }
+        }
+        if (newTipIndex >= 0) {
             if (!outTip.activeSelf) outTip.SetActive(true);
         } else {
             if (outTip.activeSelf) outTip.SetActive(false);