void OnDestroy() { if (AerowandDevice != null && closed == false) { AerowandWindowsBluetooth.CloseDevices(); closed = true; } }
void OnEnable() { position = Vector3.zero; orientation = Quaternion.identity; positionRaw = Vector3.zero; orientationRaw = Quaternion.identity; packetHz = 0.0f; foreach (AEROWAND_BUTTONS button in Enum.GetValues(typeof(AEROWAND_BUTTONS))) { buttonDictionary.Add(button, new ButtonState()); } if (AerowandDevice == null) { switch (connectionType) { case ConnectionType.AEROWAND_USBHOST: #if (UNITY_ANDROID && !UNITY_EDITOR) AerowandDevice = new AerowandAndroidWrapper(AerowandAndroidWrapper.StreamSource.Usb); #elif (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN) if (init == false) { AerowandWindowsBluetooth.InitializeDevices(); init = true; } debug = new AerowandWindowsBluetooth(connectionType); AerowandDevice = debug; #endif break; case ConnectionType.AEROWAND_BLUETOOTHCLASSIC: #if (UNITY_ANDROID && !UNITY_EDITOR) AerowandDevice = new AerowandAndroidWrapper(AerowandAndroidWrapper.StreamSource.Bluetooth); #elif (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN) if (init == false) { AerowandWindowsBluetooth.InitializeDevices(); init = true; } debug = new AerowandWindowsBluetooth(connectionType); AerowandDevice = debug; #endif break; default: break; } } switch (connectionType) { case ConnectionType.AEROWAND_USBHOST: if (AerowandHead == null) { AerowandHead = this; } break; case ConnectionType.AEROWAND_BLUETOOTHCLASSIC: if (AerowandHand == null) { AerowandHand = this; } break; default: break; } }