|
|
@@ -172,6 +172,20 @@ public class BluetoothAim : MonoBehaviour
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ #if UNITY_ANDROID
|
|
|
+ using (var helper = new AndroidJavaClass("com.example.smartbowlib.BluetoothHelper"))
|
|
|
+ {
|
|
|
+ using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
|
|
+ {
|
|
|
+ using (var context = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
|
|
|
+ {
|
|
|
+ bool ok = helper.CallStatic<bool>("requestPermissions", context);
|
|
|
+ if (!ok) throw new Exception("安卓12的蓝牙权限-尚未授权");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+
|
|
|
BluetoothHelper.BLE = true;
|
|
|
bluetoothHelper = BluetoothHelper.GetNewInstance();
|
|
|
|