pluxbiosignals / unity-sample

Unity Sample APP intended to show a practical integration of PLUX devices with the Unity environment, encompassing functionalities such as: the search of compatible Bluetooth devices and also the start/stop of a real-time acquisition.
15 stars 3 forks source link

How to introduce the two callbacks “ScanResults” and “ConnectionDone” #7

Closed yukih00 closed 4 years ago

yukih00 commented 4 years ago

Thank you for the excellent device and API.

I have a basic question about how to use the API with PsychoBIT. I have tried to create a Unity content that measures EDA and Plus data while a user plays the content. However, I cannot understand how to introduce the two callbacks “ScanResults” and “ConnectionDone.” Should I write the two codes in a C# script? For example,

public class Bitalino : MonoBehaviour { public void ScanResults(List listDevices); public void ConnectionDone();

// Start is called before the first frame update
void Start()
{

}

}

Because I am novice for Unity and C#, this question would be foolish. I hope to receive an answer of the question.

GRamosPlux commented 4 years ago

Dear yukih00,

Our team is truly grateful for your kind words! Regarding the presented question, it will be a pleasure to support you.

Your assumption is correct, in order to use the callbacks it will be necessary to write their implementation inside your script in the following way:

public void ScanResults(List<string> listDevices)
{
      // Instructions executed once the Bluetooth scan reaches its end, containing **listDevices** the list of found devices
}

public void ConnectionDone()
{
      // Instructions that should be executed after connection have been established
}

After implementing the callbacks the remaining step is to mention them as inputs of the constructor PluxDeviceManager:

// Start is called before the first frame update
void Start()
{
      // Initialise object
      pluxDevManager = new PluxDeviceManager(ScanResults, ConnectionDone);
}

To complement the previous instructions, an illustrative script (shared by a user of our community in another support task) is available at: https://drive.google.com/file/d/126yiLXm0noW5gqjimD1DOyfIbh1Jhkb7/view?usp=sharing

I truly hope that the previous information could be helpful, however, if you don't consider it totally enlightening or if further questions arise, please, do not hesitate to alert us!

My best and sincere regards, GRamosPlux

yukih00 commented 4 years ago

Dear GRamosPlux,

Thank you for helpful comments and providing a sample script. Due to those, I can connet my device with Unity.

If I find any troubles, I may ask you about that.

Best regards, Yukih00

GRamosPlux commented 4 years ago

Dear yukih00,

I am truly glad for understanding that the previous information was useful, these are really positive news!

Of course, if any further question arise, please, do not hesitate to request our support. For now I will close this issue, but, if necessary it can be reopened in the future.

I wish you a good experience with PLUX devices and API's.

My best and sincere regards, GRamosPlux