-
Notifications
You must be signed in to change notification settings - Fork 7
SingularityManager Component
The SingularityManager
is the most important component exposed to you in the singularity. It acts as the interface between C# code in Unity, and Java/Kotlin code in the base android layer that actually runs the Bluetooth communication.
It's a monobehavior script, which means you can add it to a Unity GameObject as you would any other Unity script.
It exposes three UnityEvents:
-
onConnected()
, called when the SingularityManager successfully connects to a device. -
onMessageRecieved(string message)
, called when the headset receives a message from a connected Bluetooth device -
onError(string errorMessage)
, called when an error occurs
You can connect these UnityEvents to call methods in your own scripts through the inspector.
The SingularityManager
has these public methods:
public List<DeviceSignature> GetPairedDevices()
public void ConnectToDevice(DeviceSignature sig)
public void sendMessage(string message, DeviceSignature sig)
public void DisconnectDevice(DeviceSignature sig)
public void DisconnectAll()
Returns a List
of all the DeviceSignatures
that are paired (but not necessarily connected) to the VR headset. Useful if you are trying to make a GUI to choose a device to connect to.
Arguments: None.
Attempts a connection with the device specified. If succeeds, will invoke onConnected()
and start listening for messages. If fails, will invoke onError(string errorMessage)
.
Arguments:
-
DeviceSignature
sig: the signature of the paired device you want to connect to.
Attempts to send a message over Bluetooth to the specified connected device.
Arguments:
-
DeviceSignature
sig: the signature of the connected device you want to send a message to. -
string
message: The message to send to the device.
Disconnects from the specified connected device.
Arguments
-
DeviceSignature
sig: the signature of the connected device you want to disconnect from.
Disconnects from all connected devices.
Arguments: None