lvjincheng 4 anni fa
parent
commit
605e6c7371

+ 5 - 3
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -128,9 +128,7 @@ public class BluetoothAim : MonoBehaviour
                 }
                 CallDelay(1, OpenInfrared);
                 CallDelay(2, OpenReceiveData);
-                CallDelay(3, delegate() {
-                    WriteData(SceneManager.GetActiveScene().name.StartsWith("Game") ? "b" :"B");
-                });
+                CallDelay(3, RequestBattery);
             };
             bluetoothHelper.OnConnectionFailed += (BluetoothHelper helper) =>
             {
@@ -191,6 +189,10 @@ public class BluetoothAim : MonoBehaviour
         Log("瞄准模块准备完成\n" + deviceName);
     }
 
+    public void RequestBattery() {
+        WriteData("b");
+    }
+
     void CallDelay(float delayTime, TweenCallback callback)
     {
         Sequence sequence = DOTween.Sequence();

+ 1 - 1
Assets/BowArrow/Scripts/View/DeviceBatteryView.cs

@@ -51,7 +51,7 @@ public class DeviceBatteryView : MonoBehaviour
     {
         try {
             if (BluetoothAim.ins.hasData && JC.CS.Utility.GetTimestamp() - BluetoothAim.ins.hasDataTime > 3000) {
-                BluetoothAim.ins.WriteData(SceneManager.GetActiveScene().name.StartsWith("Game") ? "b" :"B");
+                BluetoothAim.ins.RequestBattery();
             }
         } catch (Exception) {}
     }