DanielYu6 / BlueUnity

Plugin for using bluetooth (like HC-05, HC-06) with unity3d on android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BlueUnity

BlueUnity is a plugin for using Bluetooth with Unity3d on Android.

Installation

Import UnityAndroidBluetooth.unitypackage into a Unity project. In the Scenes folder you will find a scene "SampleScene" to test the Bluetooth plugin.

Usage

  1. Build the game using SampleScene or use the one I already built (see in 'Use this build to test').

  2. Pair your Bluetooth device with baud rate of 9600 to your android phone.

  3. Open the app.

  4. Enter the name of the Bluetooth device, click Start.

  5. Enter data in the input filed named "Enter Data to send" and click send.

  6. To see incoming data, draw a circle in the screen with your finger to see a the Log Viewer (Unity-Logs-Viewer from assets store)

See this video for a walkthrough (sorry for the low volume).

Note: The plugin parses incoming data with inputBuffer.readLine(), which reads until it reaches a new line character ('\n').

Bluetooth Compatibility

BlueUnity was tested on HC-05, HC-06 and BM78 Bluetooth modules also with ESP32, using the standard Bluetooth library (BluetoothSerial.h).

Adapting to Your Project

If you want to edit the plugin and adapt it on your needs, check the "Android Studio src" file that contains the code of the plugin, and see this video by CWGTech on Creating an Android plugin for Unity3D.

Notes:

  • BluetoothPlugin is the Android Project if you want to check the code and make changes on the Jar file.

  • In folder Assets\Plugins you will find the Android plugin named classes, AndroidManifest (for adding Bluetooth permission) and C# script for handling the plugin.

  • In Assets folder you will find a script (BluetoothTest) that contains function assigned to buttons to Start, Stop and send data to Bluetooth.

Contributing or Questions

Contact: bentalebahmed98@gmail.com

License

MIT

About

Plugin for using bluetooth (like HC-05, HC-06) with unity3d on android

License:MIT License