Our goal in Unity is to output a serial message to Feather over USB, indicating which cube was activated via focusing with the NextMind.
To get our project up & running quickly, you can duplicate and edit example scenes included in the NextMind SDK package.
In your Unity project’s Project pane, navigate to Assets -> NextMindSDK -> Examples folder. Copy the scene titled Hub, paste it into Assets -> Scenes, and change its name to Hub_edit.
Do the same with:
- Assets/NextMindSDK/Examples/Calibration/Calibration scene
- & Assets/NextMindSDK/Examples/SDKDiscovery/SDKDiscovery scene
Your Scenes folder should look like the image below:
Finally, open the SDKDiscovery-edit scene and delete all child objects of the ScenePanels object.
Create a new child object of ScenePanels and name it Neurotags
Copy the CubeTag prefab from Assets/NextMindSDK/Core/Runtime/Prefabs/NeuroTags/ and paste it as a child of Neurotags a total of three times.
Rename those newly pasted CubeTag objects to CubeTagA, CubeTagB, CubeTagC
Your scene hierarchy should now look like the above example.
Click the button below to download a zip file containing the following two scripts:
- SerialComms.cs
- TelekinesisStep.cs
Unzip the downloaded file.
Add the TelekinesisStep script to the NeuroTags object.
Add the SerialComms script to the ScenePanels object
Note the Com_port_number field in the Serial Comms script. This is the serial port for the Feather – we’ll fill this in later.
In CubeTagA, under Tracking Events, click the plus button under On Triggered ().
Click and drag the ScenePanels object from the Hierarchy pane and release it over the field labelled None (object).
Click on the pull-down menu labelled No Function and choose Serial Comms -> TriggerFirst
Repeat the process for CubeTagB, choosing TriggerSecond, & CubeTagC, choosing TriggerThird
Open the Project Settings window and make the following changes:
- Player -> Other Settings -> Active Input Handling – set to Both
- Player -> Other Settings -> API Compatibility – set to .NET 4.x
Finally, open the Hub-edit scene and locate the object in the scene hierarchy named SDKDiscoveryGroup. Within that object's Button script, edit the target variable of On Click () to read SDKDiscovery-edit.
Now the Discover button in the main menu will load our test scene equipped with serial communication.