在Unity应用程序中为Hololens显示设备使用许可对话框

我正在研究在Unity上构建Hololens的应用程序。 我的需求是使用Bluetooth Service Port Profile从手机(android或wp – 并不重要)获取一些信息。 选择的方法是使Hololens充当蓝牙主机。 所以我正在使用RfcommServiceProvider 。 简化样本:

 _rfcommProvider = await RfcommServiceProvider.CreateAsync(RfcommServiceId.SerialPort); _socketListener = new StreamSocketListener(); _socketListener.ConnectionReceived += OnConnectionReceived; await _socketListener.BindServiceNameAsync(_rfcommProvider.ServiceId.AsString(), SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication); _rfcommProvider.StartAdvertising(_socketListener, true); 

和事件处理程序如:

 private async void OnConnectionReceived(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args) { _socket = args.Socket; ... } 

接下来是问题:当客户端设备尝试连接时 – 用户需要为此应用/设备对授予权限。 如果在hololens上的UWP应用程序中使用此代码,则会出现系统同意对话框。 但是当它是Unity应用程序时 – 它只是试图在事件处理程序中获取套接字。 要修复此用户需要关闭应用程序,请转到设置>隐私>其他设备,然后打开设备/应用程序对的切换按钮(此按钮仅在首次尝试连接到Hololens应用程序后出现)。

所以问题是:在Unity应用程序中是否有一种明确的方式或一些解决方法要求用户提供此权限?