Beispiel #1
0
        protected virtual void StartBluetoothHost(Action onReadyAction)
        {
#if !UNITY_EDITOR
            _hostAction = onReadyAction;

            // If Bluetooth is enabled, immediately start the Bluetooth server
            if (AndroidBluetoothMultiplayer.GetIsBluetoothEnabled())
            {
                AndroidBluetoothMultiplayer.RequestEnableDiscoverability(_bluetoothNetworkManagerSettings.DefaultBluetoothDiscoverabilityInterval);
                StopAll(); // Just to be sure
                AndroidBluetoothMultiplayer.StartServer((ushort)_networkManager.networkPort);
            }
            else
            {
                // Otherwise, we have to enable Bluetooth first and wait for callback
                _desiredMode = BluetoothMultiplayerMode.Server;
                AndroidBluetoothMultiplayer.RequestEnableDiscoverability(_bluetoothNetworkManagerSettings.DefaultBluetoothDiscoverabilityInterval);
            }
#else
            onReadyAction();
#endif
        }