|
|
@@ -4,6 +4,7 @@ using UnityEngine;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine.UI;
|
|
|
using DG.Tweening;
|
|
|
+using UnityEngine.SceneManagement;
|
|
|
|
|
|
public class BluetoothAim : MonoBehaviour
|
|
|
{
|
|
|
@@ -16,6 +17,7 @@ public class BluetoothAim : MonoBehaviour
|
|
|
[SerializeField] Text textUI;
|
|
|
public BluetoothStatusEnum status = BluetoothStatusEnum.Connect;
|
|
|
public bool hasData = false;
|
|
|
+ public long hasDataTime;
|
|
|
public static bool scanLock = false; //防止同时扫描冲突
|
|
|
public static BluetoothAim ins;
|
|
|
|
|
|
@@ -122,8 +124,11 @@ public class BluetoothAim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- CallDelay(1, OpenInfrared);
|
|
|
- CallDelay(2, OpenReceiveData);
|
|
|
+ CallDelay(1, delegate() {
|
|
|
+ WriteData(SceneManager.GetActiveScene().name == "Game" ? "b" :"B");
|
|
|
+ });
|
|
|
+ CallDelay(2, OpenInfrared);
|
|
|
+ CallDelay(3, OpenReceiveData);
|
|
|
};
|
|
|
bluetoothHelper.OnConnectionFailed += (BluetoothHelper helper) =>
|
|
|
{
|
|
|
@@ -132,6 +137,7 @@ public class BluetoothAim : MonoBehaviour
|
|
|
};
|
|
|
bluetoothHelper.OnCharacteristicChanged += (helper, value, characteristic) =>
|
|
|
{
|
|
|
+ if (!hasData) hasDataTime = JCUtil.GetTimestamp();
|
|
|
hasData = true;
|
|
|
byte[] bytes = value;
|
|
|
// Log(String.Join(",", bytes));
|