Unity android bluetooth plugin for study
This project is based on the BluetoothChat example. It is part of my DIY VR Controller project and was created to study how to use Android modules in Unity & Unreal.
- Since the
Bluetooth
object is a singleton, it can be accessed and used immediately. You can access Java code through theBluetooth
object.
private Bluetooth bluetooth = null;
/* ... */
bluetooth = Bluetooth.getInstance();
bluetooth.SearchDevice();
/* ... */
bluetooth.Connect(DEVICE_INFO);
- Android events are updated in the
BluetoothModel
. BluetoothModel isBtObservable
. If you want to observe updated data, you can subscribe by implementing theIBtObserver
interface.
public class BluetoothController : MonoBehaviour, IBtObserver {
private Bluetooth bluetooth;
private BluetoothModel bluetoothModel;
}
- Now, you can refer to the event method list and design it in detail. :)
Copyright 2017 The Android Open Source Project, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.