BlueUnity is a Unity plugin that provides Android Bluetooth Classic connectivity. This version is a Kotlin-based implementation that enables device scanning, pairing, server/client connections, and byte-stream communication directly from Unity.
- Automatic Bluetooth permission handling (No location permission needed)
- Check Bluetooth enabled state and request enabling
- Set device discoverability (server mode)
- Rename the device during discoverable mode
- Retrieve paired devices
- Search for nearby devices
- Connect/disconnect using MAC address
- Device-to-device (mobile, tablet, headset, etc.) communication (one server, one clients)
- Device-to-module (ESP32, HC-05/06, BM78, etc.) communication (Device as client and the module always as a server)
- Read and write byte streams
- Callback system using JavaProxy (no
Unity SendMessage)
- onDiscoveryStarted()
- onDiscoveryDeviceFound(name: String, address: String)
- onDiscoveryFinished()
- onConnecting(address: String)
- onConnected(address: String)
- onDisconnected(address: String)
- onDataReceived(data: ByteArray)
- onDataNotSent(data: ByteArray)
- onError(error: String)
Kotlin uses signed bytes (Byte, -128 to 127), while Unity uses unsigned bytes (byte, 0 to 255).
- All data received from Android arrives as signed
ByteArray - A conversion is automatically handled on the Unity side
-
Set Minimum API Level → 27
Project Settings → Player → Other Settings → Minimum API Level -
Enable Custom Main Manifest
Project Settings → Player → Publishing Settings → Custom Main Manifest -
Unity 6 only:
Set Application Entry Point to Activity
Project Settings → Player → Other Settings -
Use the BlueUnity top-menu in Unity to:
- Validate plugin files
- Copy required Android manifest entries
Build the app with the example scene:
Assets/BlueUnity/Scenes/BluetoothManagerExample
Or install the demo APK
- Scan for nearby devices
- Enable device discoverability (shows as BlueUnity)
- Tap to connect to discovered devices
- Display paired devices
- Toggle connect with/without pairing
- Send and receive data