public async UniTask <Cube> Connect(BLEPeripheralInterface peripheral) { try { while (this.isConnecting) { await UniTask.Delay(100); } this.isConnecting = true; bool success = await this.ConnectPeripheral(peripheral); if (!success) { return(null); } var cube = new CubeUnity(peripheral as UnityPeripheral); cube.Initialize(); this.isConnecting = false; return(cube); } catch (System.Exception e) { Debug.LogError(e); this.isConnecting = false; return(null); } }
public async UniTask <Cube> Connect(BLEPeripheralInterface peripheral) { var uniperipheral = peripheral as UnityPeripheral; var cube = new CubeUnity(uniperipheral.obj); while (!cube.isConnected) { await UniTask.Delay(50); } cube.Init(); return(cube as Cube); }