public void ConnectTo(BluetoothPeripheralParams newPeripheralParams) { if (_peripheralParams.HasValue && newPeripheralParams.Equals(_peripheralParams.Value)) { logger.Warning("Already connected to this peripheral: " + newPeripheralParams); return; } #if UNITY_EDITOR _state = States.None; _connected = true; if (OnConnect != null) { OnConnect(); } return; #endif ResetState(() => { _peripheralParams = newPeripheralParams; BluetoothLEHardwareInterface.Initialize(true, false, () => { logger.DebugLog("Initialized bluetooth hardware interface."); SetState(States.Scan, 0.1f); }, (error) => { logger.Error("Error initializing bluetooth hardware interface: " + error); }); }); }