private void OnDestroy() { NeuroManager neuroManager = NeuroManager.Instance; if (neuroManager) { neuroManager.onDeviceConnected.RemoveListener(OnDeviceConnected); neuroManager.onDeviceDisconnected.RemoveListener(OnDeviceDisconnected); } }
/// <summary> /// Get the connected device if it exists and start listening to the connections/disconnections. /// </summary> private void Initialize() { NeuroManager neuroManager = NeuroManager.Instance; if (neuroManager.ConnectedDevices.Count > 0) { OnDeviceConnected(neuroManager.ConnectedDevices[0]); } neuroManager.onDeviceConnected.AddListener(OnDeviceConnected); neuroManager.onDeviceDisconnected.AddListener(OnDeviceDisconnected); }
public override void OnExitStep() { Clean(); // Unregister from the connection events NeuroManager neuroManager = NeuroManager.Instance; neuroManager.onDeviceAvailable.RemoveListener(OnDeviceAvailable); neuroManager.onDeviceUnavailable.RemoveListener(OnDeviceUnavailable); neuroManager.onScanningStarted.RemoveListener(OnScanningStarted); neuroManager.onScanningStopped.RemoveListener(OnScanningStopped); neuroManager.onDeviceEvent.RemoveListener(OnDeviceEventReceived); }
public override void OnEnterStep() { devicesByID = new Dictionary <uint, DeviceUIElement>(); InitList(); NeuroManager neuroManager = NeuroManager.Instance; ShowLoading(neuroManager.IsScanning); // Register to the connection events neuroManager.onDeviceAvailable.AddListener(OnDeviceAvailable); neuroManager.onDeviceUnavailable.AddListener(OnDeviceUnavailable); neuroManager.onScanningStarted.AddListener(OnScanningStarted); neuroManager.onScanningStopped.AddListener(OnScanningStopped); // Listen for devices entering pairing mode neuroManager.onDeviceEvent.AddListener(OnDeviceEventReceived); }
public override void OnEnterStep() { devicesByID = new Dictionary <uint, DeviceUIElement>(); InitList(); NeuroManager neuroManager = NeuroManager.Instance; nextButton.interactable = neuroManager.ConnectedDevices.Count > 0; ShowLoading(neuroManager.IsScanning); // Register to the connection events neuroManager.onDeviceAvailable.AddListener(OnDeviceAvailable); neuroManager.onDeviceUnavailable.AddListener(OnDeviceUnavailable); neuroManager.onScanningStarted.AddListener(OnScanningStarted); neuroManager.onScanningStopped.AddListener(OnScanningStopped); neuroManager.onDeviceConnected.AddListener(OnDeviceConnected); }