Explorar el Código

蓝牙安卓12修复

lvjincheng hace 3 años
padre
commit
8801734ec4

+ 14 - 0
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -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();
 

BIN
Assets/Plugins/Android/smartbowlib-debug.aar