Преглед изворни кода

Merge branch 'new-ui-infrared' of https://git.b-beng.cn/yichael/SmartBow into new-ui-infrared

ZIM пре 1 година
родитељ
комит
b09a97c34d

+ 41 - 4
Assets/BowArrow/InfraredCamera/InfraredDemo.cs

@@ -128,6 +128,9 @@ public class InfraredDemo : MonoBehaviour
     //亮度过滤阈值
     public ParamFloatValue infraredFileterValue = new ParamFloatValue("ic_infraredFileterValue", 0.8f);
 
+    //十字准心
+    public ParamFloatValue crosshairValue = new ParamFloatValue("ic_crosshairValue",0);
+
     public static InfraredCameraHelper infraredCameraHelper;
     public static bool running { get => infraredCameraHelper != null; }
     private bool _inited;
@@ -366,6 +369,8 @@ public class InfraredDemo : MonoBehaviour
             infraredCameraHelper.Create();
             infraredCameraHelper.OnPositionUpdate += (Vector2 point) =>
             {
+                //跑九轴时候,不处理这里位置
+                if (AimHandler.ins && AimHandler.ins.bRuning9Axis()) return;
                 if (Camera.main == null) return;
                 Ray ray = Camera.main.ScreenPointToRay(point);
                 Vector3 rayEndPoint = ray.GetPoint(200);
@@ -426,6 +431,14 @@ public class InfraredDemo : MonoBehaviour
 
     }
 
+    public int getCrosshairValue() {
+       return (int)crosshairValue.Get();
+    }
+
+    public void setCrosshairValue(bool bshow) {
+        crosshairValue.Set(bshow?1:0);
+    }
+
     public void onStartPreview()
     {
         infraredCameraHelper.onStartPreview();
@@ -670,9 +683,19 @@ public class InfraredDemo : MonoBehaviour
             UInt64 _VALUE = currentCameraInfo.GetTypeByName(typeStr);
             UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
             float v = currentCameraInfo.GetValue(_VALUE); // infraredCameraHelper.GetBrightness();
-            float v2 = (v / _UVCCtrlInfo.max) * 10;
+            //float v2 = (v / _UVCCtrlInfo.max) * 10;
+
+            // 目标区间 [0, 10] 的边界值
+            double targetMin = 0.0;
+            double targetMax = 10.0;
+            double originalMin = _UVCCtrlInfo.min;
+            double originalMax = _UVCCtrlInfo.max;
+            // 计算转换后的值
+            double v2 = MapValue(v, originalMin, originalMax, targetMin, targetMax);
+
+
             Debug.Log("获取相机的感光度:" + _VALUE + " = " + v + " = " + v2);
-            _slider.SetValueWithoutNotify(v2);
+            _slider.SetValueWithoutNotify((float)v2);
         }
         else _slider.SetValueWithoutNotify(5);
     }
@@ -694,8 +717,16 @@ public class InfraredDemo : MonoBehaviour
             UVCCtrlInfo _UVCCtrlInfo = currentCameraInfo.GetInfo(_VALUE);
             int _currentUVCValue = currentCameraInfo.GetValue(_VALUE);
             //value 0 ~ 10
-            int _current = (int)(_UVCCtrlInfo.max * value / 10);
-            Debug.Log("_current:" + value);
+            // 原始区间和目标区间的边界值
+            double originalMin = 0.0;
+            double originalMax = 10.0;
+            double targetMin = _UVCCtrlInfo.min;
+            double targetMax = _UVCCtrlInfo.max;
+            // 计算转换后的值
+            double result = MapValue(value, originalMin, originalMax, targetMin, targetMax);
+
+            int _current = (int)(result);
+            Debug.Log("_current:" + value + " , result:" + result);
             textObj.text = _current + "";
             slider.value = _current;
             //dUVCParameters.GetValueOrDefault(typeStr).Set(_current);
@@ -704,6 +735,12 @@ public class InfraredDemo : MonoBehaviour
 
         }
     }
+
+    double MapValue(double value, double originalMin, double originalMax, double targetMin, double targetMax)
+    {
+        // 线性插值公式
+        return targetMin + (value - originalMin) * (targetMax - targetMin) / (originalMax - originalMin);
+    }
     #endregion
 
 

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

@@ -6165,7 +6165,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: 29.692308, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &589339043
@@ -7713,9 +7713,9 @@ RectTransform:
   m_Father: {fileID: 1349314726}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 29.692308, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 29.692308, y: -16.5}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &694545845
@@ -13370,7 +13370,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: 29.692308, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1218454288
@@ -21174,7 +21174,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: 79.38461, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 40}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1845023679

+ 21 - 5
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -243,7 +243,8 @@ public class AimDeviceInfos
     [NonSerialized] public float lerpTimeRate = 7;
     public void Update()
     {
-        if (m_controlObj && !m_ban9AxisCalculate && !InfraredDemo.running)
+        //&& !InfraredDemo.running
+        if (m_controlObj && !m_ban9AxisCalculate && bRuning9Axis())
         {
             if (lerpForRotation)
                 m_controlObj.localRotation = Quaternion.Lerp(m_controlObj.localRotation, newRotation, Time.deltaTime * lerpTimeRate);   
@@ -311,12 +312,16 @@ public class AimDeviceInfos
             return;
         }
 
-        if (InfraredDemo.running)
+        //if (InfraredDemo.running)
+        //{
+        //    BluetoothAim.ins.WriteData("4"); //关闭九轴
+        //    return;
+        //}
+
+        if (!bRuning9Axis())
         {
-            BluetoothAim.ins.WriteData("4"); //关闭九轴
             return;
         }
-        
         m_axisHandler.Update(bytes);
 
         if (BowQuatDebug.ins) BowQuatDebug.ins.ShowModuleQuat(newRotation.eulerAngles);
@@ -346,8 +351,9 @@ public class AimDeviceInfos
 
     public void DoIdentity()
     {
-        if (InfraredDemo.running) return;
+        //if (InfraredDemo.running) return;
         m_axisHandler.DoIdentity();
+        if (!bRuning9Axis()) return;
         if (m_controlObj) m_controlObj.localRotation = newRotation;
     }
     public void NotifyAxisOnShot() { m_axisHandler.NotifyAxisOnShot(); }
@@ -362,4 +368,14 @@ public class AimDeviceInfos
     public IEnumerator SaveGyr() { return m_axisHandler.SaveGyr(); }
     public IEnumerator SaveMag() { return m_axisHandler.SaveMag(); }
     public void ResumeCalibrateRecord(string record) { m_axisHandler.ResumeCalibrateRecord(record); }
+
+
+    #region 获取一个连接的设备下,对应的 Archery 是运行9轴的代码处理位置信息判断
+    public bool bRuning9Axis() {
+        bool bRuning = false;
+        //连接的设备下,对应的 Archery 是运行9轴的代码处理位置信息判断
+        bRuning = GlobalData.MyDeviceMode == DeviceMode.Archery;
+        return bRuning;
+    }
+    #endregion
 }

+ 2 - 2
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -910,11 +910,11 @@ public class BluetoothAim : MonoBehaviour
             CallDelay(1, () =>
             {
                 Debug.Log("Connect*********");
-                smartBowHelper2P.Connect(userTags,deviceId2);
+                smartBowHelper2P.Connect(userTags,deviceId2,true);//不在sdk 判断mac
             });
         }
         else {
-            smartBowHelper2P.Connect(userTags, deviceId2);
+            smartBowHelper2P.Connect(userTags, deviceId2,true);
         }
     }
 

+ 8 - 1
Assets/BowArrow/Scripts/Effect/HitTargetNumber.cs

@@ -26,9 +26,15 @@ public class HitTargetNumber : MonoBehaviour
             Destroy(this.gameObject);
         });
     }
-
+    static List<GameObject> hitTargetNumber = new();
     public static void Create(float number) {
         if (number <= 0) return;
+        //清空对象
+        for (int i = hitTargetNumber.Count - 1; i >= 0; i--)
+        {
+            Destroy(hitTargetNumber[i].gameObject);
+            hitTargetNumber.RemoveAt(i);
+        }
         GameObject o = GameObject.Instantiate(
             Resources.Load<GameObject>("Prefabs/Effects/HitTargetNumber"),
             Vector3.zero,
@@ -37,5 +43,6 @@ public class HitTargetNumber : MonoBehaviour
         );
         o.transform.localPosition = new Vector3(340, 180, 0);
         o.GetComponentInChildren<Text>().text = number.ToString($"f{CommonConfig.ringsPrecision}");
+        hitTargetNumber.Add(o);
     }
 }

+ 6 - 1
Assets/BowArrow/Scripts/Expand/AutoResetView.cs

@@ -16,7 +16,12 @@ public class AutoResetView : MonoBehaviour
     public static Action onInstantiate;
 
     public static void DoIdentity() {
-        if (InfraredDemo.running) return;
+        //if (InfraredDemo.running) return;
+        //如果不是运行九轴,不进行校准页面
+        if (!AimHandler.ins.bRuning9Axis())
+        {
+            return;
+        }
         if (SceneManager.GetActiveScene().name.StartsWith("GameDouble"))
         {
             if (GameObject.Find("AutoResetViewNewLeft")) return;

+ 5 - 1
Assets/BowArrow/Scripts/Expand/SB_EventSystem.cs

@@ -79,7 +79,11 @@ public class SB_EventSystem : MonoBehaviour
         }
         void UpdateMoveSimulateMouse() {
             if (!simulateMouseIsAwaked) return;
-            if (InfraredDemo.running) return;
+            //if (InfraredDemo.running) return;
+            if (!AimHandler.ins.bRuning9Axis())
+            {
+                return;
+            }
             nowAxisQuat = Quaternion.Lerp(nowAxisQuat, newAxisQuat, 0.033f * 8);
             Vector3 resEulerAngles = FormatQuat(nowAxisQuat).eulerAngles;
             resEulerAngles.x = Mathf.Clamp(resEulerAngles.x > 180 ? resEulerAngles.x - 360 : resEulerAngles.x, -12.5f, 12.5f);

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

@@ -59,7 +59,8 @@ public class Arrow : MonoBehaviour
         mySpeed = speed;
 
         Billboard.ins?.SetArrowSpeed(speed);
-        if (GameAssistUI.ins)
+        //Debug.Log("speed:"+ speed);
+        if (GameAssistUI.ins && GlobalData.MyDeviceMode == DeviceMode.Archery)
         {
             mySpeed *= GameAssistUI.ins.shootScaleValue;
             Billboard.ins?.SetArrowSpeedScale(GameAssistUI.ins.shootScaleValue);

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

@@ -12,6 +12,8 @@ public class CrossHair : MonoBehaviour
     private bool visiable = false;
     private bool onlyShow = true;
 
+    private GameObject infraredGuiderObj;
+
     void Awake()
     {
         ins = this;
@@ -31,12 +33,22 @@ public class CrossHair : MonoBehaviour
         //如果是靶子场景,把准心改为黑色
         if (SceneManager.GetActiveScene().name.Equals("Game")) {
             this.image.color = Color.black;
+
+            infraredGuiderObj =  FindObjectOfType<InfraredGuider>().gameObject;
         }
     }
 
     void Update()
     {
-        if (open) SetVisiable(onlyShow && ArmBow.ins && ArmBow.ins.IsCanShoot());
+        //如果是新手指引的情况
+        if (infraredGuiderObj != null && infraredGuiderObj.activeSelf == true)
+        {
+            SetVisiable(true);
+        }
+        else {
+            //按照条件显示图标
+            if (open) SetVisiable(onlyShow && ArmBow.ins && ArmBow.ins.IsCanShoot());
+        }
     }
 
     void SetVisiable(bool value)

+ 4 - 0
Assets/BowArrow/Scripts/Game/GameAssistUI.cs

@@ -80,6 +80,8 @@ public class GameAssistUI : MonoBehaviour
             //显示控制准心按钮
             Button crossHairBtn = transform.Find("Button5").GetComponent<Button>();
             crossHairBtn.gameObject.SetActive(true);
+            //设置准心是否显示
+            CrossHair.ins.SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
             bool onInitOpen = CrossHair.ins.GetOpen() && CrossHair.ins.GetOnlyShow();
             Image crossHairImage = crossHairBtn.GetComponentInChildren<Image>();
             crossHairImage.material = onInitOpen? outlight:null;
@@ -87,6 +89,8 @@ public class GameAssistUI : MonoBehaviour
                 AudioMgr.ins.PlayBtn();
                 bool onlyShow = !CrossHair.ins.GetOnlyShow();
                 CrossHair.ins.SetOnlyShow(onlyShow);
+                //保存准心状态
+                InfraredDemo._ins.setCrosshairValue(onlyShow);
                 if (onlyShow)
                 {
                    crossHairImage.material = outlight;

+ 1 - 1
Assets/BowArrow/Scripts/Manager/GameMgr.cs

@@ -112,7 +112,7 @@ public class GameMgr : MonoBehaviour
         if (bShowDistance) {
             if (gameType > 0)
             {
-                if (!UserSettings.ins.deviceCalibrateGuideFinish && !InfraredDemo.running)
+                if (!UserSettings.ins.deviceCalibrateGuideFinish) //&& !InfraredDemo.running
                 {
                     DeviceCalibrateView.Create();
                     return;

+ 53 - 53
Assets/DuckHunter/Scenes/DuckHunter.unity

@@ -156,10 +156,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 324.44968, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &8255550
 MonoBehaviour:
@@ -723,10 +723,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 7
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 559.94324, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &195083055
 MonoBehaviour:
@@ -1521,10 +1521,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 442.19644, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &375182103
 MonoBehaviour:
@@ -1598,10 +1598,10 @@ RectTransform:
   m_Father: {fileID: 1870892486}
   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: 77.69231, y: -36.76923}
-  m_SizeDelta: {x: 115.38461, y: 53.53846}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &383075945
 MonoBehaviour:
@@ -2104,7 +2104,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 0
+  m_IsActive: 1
 --- !u!224 &537447197
 RectTransform:
   m_ObjectHideFlags: 0
@@ -2520,10 +2520,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 10
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 736.5633, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &619573016
 MonoBehaviour:
@@ -2922,10 +2922,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 9
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 677.68994, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &711804451
 MonoBehaviour:
@@ -3074,10 +3074,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 206.70294, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &792593345
 MonoBehaviour:
@@ -3382,10 +3382,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 4
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 383.32306, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &871807299
 MonoBehaviour:
@@ -3621,10 +3621,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 6
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 501.06982, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &909695382
 MonoBehaviour:
@@ -4079,9 +4079,9 @@ RectTransform:
   m_Father: {fileID: 212105003}
   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: 199.5, y: -66.5}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 330, y: 54}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!1 &1022851687
@@ -4574,10 +4574,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   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: 107.383125, y: -67}
-  m_SizeDelta: {x: 134.76625, y: 53.53846}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1158871796
 MonoBehaviour:
@@ -5352,10 +5352,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 265.5763, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1417795436
 MonoBehaviour:
@@ -6016,10 +6016,10 @@ RectTransform:
   m_Father: {fileID: 433602508}
   m_RootOrder: 8
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 618.8166, y: -67}
-  m_SizeDelta: {x: 53.873375, y: 45}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1644947641
 MonoBehaviour:
@@ -6605,7 +6605,7 @@ RectTransform:
   m_AnchorMin: {x: 0.5, y: 0}
   m_AnchorMax: {x: 0.5, y: 0}
   m_AnchoredPosition: {x: 0, y: 100}
-  m_SizeDelta: {x: 155.38461, y: 73.53846}
+  m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0}
 --- !u!114 &1870892487
 MonoBehaviour:

+ 3 - 0
Assets/DuckHunter/Scripts/CrossHair.cs

@@ -29,6 +29,9 @@ namespace DuckHunter
 
             CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
             outBoundChecker.crossHair = transform as RectTransform;
+
+            //读取准心值
+           SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
         }
         void Update()
         {

+ 3 - 1
Assets/DuckHunter/Scripts/GameUI.cs

@@ -37,11 +37,13 @@ namespace DuckHunter
                 btnAim.gameObject.SetActive(false);
 
                 btnCrosshair.gameObject.SetActive(true);
+           
                 btnCrosshair.onClick.AddListener(delegate () {
                     AudioManager.Instance.PlayBtn();
                     bool onlyShow = !CrossHair.Instance.GetOnlyShow();
                     CrossHair.Instance.SetOnlyShow(onlyShow);
-
+                    //记录准心值
+                    InfraredDemo._ins.setCrosshairValue(onlyShow);
                 });
             }
             else {

+ 2 - 1
Assets/DuckHunter/Scripts/SmartBowController.cs

@@ -12,7 +12,8 @@ namespace DuckHunter
         void Start() {
             Instance = this;
             SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
-            if (InfraredDemo.running)
+            //InfraredDemo.running
+            if (!AimHandler.ins.bRuning9Axis())
             {
                 InfraredDemo.infraredCameraHelper.OnPositionUpdate += (p) =>
                 {

+ 23 - 8
Assets/FruitMaster/Scripts/GamingManager.cs

@@ -132,7 +132,8 @@ public class GamingManager : MonoBehaviour
     private void OnDestroy()
     {
         if (ShootCheck.ins) ShootCheck.ins.OnGameShoot -= SmartBowFireArrow;
-        if (InfraredDemo.running) InfraredDemo.infraredCameraHelper.OnPositionUpdate -= UpdateCrossHairPosition;
+        //InfraredDemo.running
+        if (!AimHandler.ins.bRuning9Axis()) InfraredDemo.infraredCameraHelper.OnPositionUpdate -= UpdateCrossHairPosition;
     }
 
     // Update is called once per frame
@@ -193,7 +194,7 @@ public class GamingManager : MonoBehaviour
             }
 
             // update aiming cross position
-            if (BowCamera.isTouchMode == false && !InfraredDemo.running)
+            if (BowCamera.isTouchMode == false && AimHandler.ins.bRuning9Axis())//!InfraredDemo.running
             {
                 Vector3 raw_screen_pos = Cam.WorldToScreenPoint(Cam.transform.position + (CurrentRotation * Vector3.forward));
                 float dist_to_mid_x = (raw_screen_pos.x - ScreenMidPoint.x) * AimingCrossPosMultiplier;
@@ -286,8 +287,15 @@ public class GamingManager : MonoBehaviour
     {
         Debug.Assert(FruitsInField.Count == 0);
 
-        CameraToLook.ins.onParseRotation += UpdateRotation;
-        if (InfraredDemo.running) InfraredDemo.infraredCameraHelper.OnPositionUpdate += UpdateCrossHairPosition;
+    
+        //InfraredDemo.running
+        if (AimHandler.ins.bRuning9Axis())
+        {
+            CameraToLook.ins.onParseRotation += UpdateRotation;
+        }
+        else {
+            InfraredDemo.infraredCameraHelper.OnPositionUpdate += UpdateCrossHairPosition;
+        }
 
         Scores = StartScores;
         uploadScore = Scores;
@@ -481,9 +489,16 @@ public class GamingManager : MonoBehaviour
         Cannon.ResetPos();
         Cannon.OnCannonFire -= SpawnAFruit;
 
-        CameraToLook.ins.onParseRotation -= UpdateRotation;
-        if (InfraredDemo.running) InfraredDemo.infraredCameraHelper.OnPositionUpdate -= UpdateCrossHairPosition;
-
+        //CameraToLook.ins.onParseRotation -= UpdateRotation;
+        //if (InfraredDemo.running) InfraredDemo.infraredCameraHelper.OnPositionUpdate -= UpdateCrossHairPosition;
+        if (AimHandler.ins.bRuning9Axis())
+        {
+            CameraToLook.ins.onParseRotation -= UpdateRotation;
+        }
+        else
+        {
+            InfraredDemo.infraredCameraHelper.OnPositionUpdate -= UpdateCrossHairPosition;
+        }
         // clear all fruits in the field
         foreach (var fruit in FruitsInField)
         {
@@ -573,7 +588,7 @@ public class GamingManager : MonoBehaviour
             }
             else {
                 //目前只有gun类型
-                arrow.GetComponent<ArrowBehavior>().Init(speed*2.0f, dir, true,false);
+                arrow.GetComponent<ArrowBehavior>().Init(20, dir, true,false);
                 BowFireAudio.clip = audioManager.GetRandomSound(SoundCategory.GunFire);
                 BowFireAudio.Play();
             }

+ 3 - 0
Assets/FruitMaster/Scripts/JCFruitMaster.cs

@@ -32,6 +32,9 @@ public class JCFruitMaster : MonoBehaviour
 
         this.open = UserSettings.ins.openCrossHair;
         this.visiable = aimingCross.enabled;
+
+        //读取准心值
+        SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
     }
 
     void OnDestroy()

+ 3 - 0
Assets/FruitMaster/Scripts/OverallLogics.cs

@@ -42,10 +42,13 @@ public class OverallLogics : MonoBehaviour
             ResetAimBtn.gameObject.SetActive(false);
 
             CrossHairBtn.gameObject.SetActive(true);
+           
             CrossHairBtn.onClick.AddListener(delegate ()
             {
                 bool onlyShow = !JCFruitMaster.ins.GetOnlyShow();
                 JCFruitMaster.ins.SetOnlyShow(onlyShow);
+                //记录准心值
+                InfraredDemo._ins.setCrosshairValue(onlyShow);
             });
         }
         else

+ 8 - 8
Assets/InfraredProject/WebCamera/Script/ZIM/ScreenLocate.cs

@@ -80,7 +80,7 @@ public partial class ScreenLocate : MonoBehaviour
     public RectTransform ScreenQuad;
     public Toggle SaveToggle;
 
-    //public Vector2 ScreenLocateCameraSize;       // 屏幕识别需要的目标分辨率,摄像机分辨率变化时该分辨率也会跟着调整
+    public Vector2 ScreenLocateCameraSize;       // 屏幕识别需要的目标分辨率,摄像机分辨率变化时该分辨率也会跟着调整
 
     public bool ShowScreenQuad = false;
 
@@ -391,11 +391,11 @@ public partial class ScreenLocate : MonoBehaviour
                     return;
                 }
 
-                //if (mUVCCameraInfo.Size != ScreenLocateCameraSize)   // 摄像机分辨率发生改变时执行
-                //{
-                //    RefreshScreenQuad(mUVCCameraInfo.Size);
-                //    return;
-                //}
+                if (mUVCCameraInfo.Size != ScreenLocateCameraSize)   // 摄像机分辨率发生改变时执行
+                {
+                    //RefreshScreenQuad(mUVCCameraInfo.Size);
+                    return;
+                }
 
                 if (mode == Mode.InfraredLocate)
                 {
@@ -638,13 +638,13 @@ public partial class ScreenLocate : MonoBehaviour
     {
         DefaultResolutionIndex = InfraredDemoMain?.ResolutionIndex ?? 0;        // 记录一下进入前的分辨率(游戏场景的分辨率,比识别时更低)
         InfraredDemoMain?.SetResolutionNew(HighScreenLocateResolutionIndex);
-        //CreateUVCTexture2DIfNeeded();
+        CreateUVCTexture2DIfNeeded();
     }
 
     public void OnLocateScreenEnd()
     {
         Debug.Log("结束捕获,当前摄像机分辨率为: " + mUVCCameraInfo.Size);
-        //ScreenLocateCameraSize = mUVCCameraInfo.Size;       // 记录本次屏幕识别的分辨率(目前采用高分辨率做识别,识别结束后调回低分辨率)
+        ScreenLocateCameraSize = mUVCCameraInfo.Size;       // 记录本次屏幕识别的分辨率(目前采用高分辨率做识别,识别结束后调回低分辨率)
         InfraredDemoMain?.SetResolutionNew(DefaultResolutionIndex);
     }
 

+ 1 - 1
Assets/SmartBow/Resources/SmartBow/Prefabs/Views/Home/InfraredScreenPositioningView.prefab

@@ -1155,7 +1155,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0, g: 0, b: 0, a: 1}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1

BIN
Assets/SmartBow/SmartBowSDK/SmartBowSDK.dll


+ 23 - 3
Assets/WildAttack/Scripts/SmartBowController.cs

@@ -13,11 +13,21 @@ namespace WildAttack
         {
             Instance = this;
             SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
-            if (InfraredDemo.running)
+            //if (InfraredDemo.running)
+            //{
+            //    InfraredDemo.infraredCameraHelper.OnPositionUpdate += OnScreenPointUpdate;
+            //}
+            //else CameraToLook.ins.onParseRotation += OnRotationUpdate;
+
+            if (AimHandler.ins.bRuning9Axis())
+            {
+                CameraToLook.ins.onParseRotation += OnRotationUpdate;
+            }
+            else 
             {
+
                 InfraredDemo.infraredCameraHelper.OnPositionUpdate += OnScreenPointUpdate;
             }
-            else CameraToLook.ins.onParseRotation += OnRotationUpdate;
 
             StartCoroutine(SetOutBoundChecker());
         }
@@ -32,8 +42,18 @@ namespace WildAttack
         void OnDestroy()
         {
             if (Instance == this) Instance = null;
-            if (InfraredDemo.running)
+            //if (InfraredDemo.running)
+            //{
+            //    InfraredDemo.infraredCameraHelper.OnPositionUpdate -= OnScreenPointUpdate;
+            //}
+
+            if (AimHandler.ins.bRuning9Axis())
+            {
+                CameraToLook.ins.onParseRotation -= OnRotationUpdate;
+            }
+            else
             {
+
                 InfraredDemo.infraredCameraHelper.OnPositionUpdate -= OnScreenPointUpdate;
             }
         }

+ 3 - 0
ProjectSettings/EditorBuildSettings.asset

@@ -41,4 +41,7 @@ EditorBuildSettings:
   - enabled: 0
     path: Assets/BowArrow/Scenes/Test.unity
     guid: 14f136990a82f0042aae1edcec1f03a2
+  - enabled: 0
+    path: Assets/InfraredProject/WebCamera/zimWebCamera.unity
+    guid: 7561eb6cd780e5e4887e30791c911a9b
   m_configObjects: {}