public void OnDestroy()
 {
     foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
     {
         // Stop all UDP sensors
         if (sensor.GetSensorType() == SensorType.EMGWiFi)
         {
             UDPSensorManager udpSensor = (UDPSensorManager)sensor;
             udpSensor.StopSensorReading();
         }
     }
 }
 private void OnApplicationQuit()
 {
     // Check if WiFi sensors are available
     foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
     {
         if (sensor.GetSensorType().Equals(SensorType.EMGWiFi))
         {
             UDPSensorManager udpSensor = (UDPSensorManager)sensor;
             udpSensor.StopSensorReading();
         }
     }
     //
     // Save and close all logs
     //
     ExperimentSystem.CloseAllExperimentLoggers();
 }