Skip to content

Commit

Permalink
update new headset scanning from 3.7 for unity example (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
tungntEmotiv authored Nov 15, 2023
1 parent a032a3c commit 03d1948
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions unity/Assets/SimpleExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ void Update()
if (!_eItf.IsAuthorizedOK)
return;

// Check to call scan headset if no session is created and no scanning headset
if (!_eItf.IsSessionCreated && !DataStreamManager.Instance.IsHeadsetScanning) {
// Start scanning headset at headset list screen
DataStreamManager.Instance.ScanHeadsets();
}

// Check buttons interactable
CheckButtonsInteractable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ public override void Activate()
base.Activate();
}

void Update() {

if (IsActive && !DataStreamManager.Instance.IsHeadsetScanning) {
// Start scanning headset at headset list screen
DataStreamManager.Instance.ScanHeadsets();
}
}

IEnumerator ChangeCanvasScaleMode(float delayTime, bool isHeadsetListForm)
{
if (isHeadsetListForm) {
Expand Down
7 changes: 5 additions & 2 deletions unity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ There are 2 examples to demo how to work with Emotiv Cortex on Unity. The first
### Example 2: SimpleExample.unity
1. Open **SimpleExample.unity** scene. It is all in one example.
2. Set the clientId, clientSecret of your application in SimpleExample.cs before running.
2. Set the clientId, clientSecret of your application in SimpleExample.cs before running.
3. Running the example. After authorizing process you able to create session with a headset. Enter a headset Id before clicking **"Create Session"** button to connect and create a session with the headset. If the text field is empty, the first headset in the headset list will be used.
4. After create session successfully, you will be able to start a record, subscribe one ore more data streams and load a profile for training.
- **Start and Stop Record:** Enter record title before starting a record, record description is optional field.
Expand All @@ -49,14 +49,17 @@ There are 2 examples to demo how to work with Emotiv Cortex on Unity. The first
- Please unload the trained data before closing.
> **Please note that:**
>
> - From Emotiv Cortex 3.7, you need to call ScanHeadsets() at DataStreamManager.cs to start headset scanning. Otherwise your headsets might not appeared in the headset list return from queryHeadsets(). If IsHeadsetScanning = false, you need re-call the ScanHeadsets() if want to re-scan headsets again but should not call ScanHeadsets() when has a headset connected.
> - The example will use **EmotivUnityItf.cs** such as a interface to do all things.
> - The subscribed data will be saved to DataBuffer as default. But you have option use data directly without DataBuffer by set '_isDataBufferUsing = false'. Please check the ouput for subcribed data at functions such as OnDevDataReceived(), OnEEGDataReceived().etc.. in EmotivUnityItf.cs
> - Please load a trained profile before subscribing **"Mental Command"** or **"Facial Expression"** data unless you only see the neutral action.

## Change log

[10 Nov 2023]
- Support new headset scanning flow from Emotiv Cortex 3.7

[15 May 2022]
- Add SimpleExample.unity to demo subscribe data, training , start record and inject marker same time.
- Remove some unused files and update Unity version to newer version (LTS 2021.3.2f1)
Expand Down

0 comments on commit 03d1948

Please sign in to comment.