public void InterpreteUDPData(byte[] data) { if (debuging) { Debug.Log("Receive data: " + Encoding.ASCII.GetString(data)); } switch (data[0]) { // Connection established case (byte)'0': switch (data [1]) { case (byte)'I': UnityEngine.Debug.Log("Connection established"); PupilTools.IsConnected = true; break; case (byte)'i': UnityEngine.Debug.Log("Connection closed"); PupilTools.IsConnected = false; break; case (byte)'S': // Start gazing command received break; case (byte)'s': // Stop gazing command received break; default: { UnityEngine.Debug.Log("Unknown response: " + (char)data[1]); debuging = false; } break; } break; case (byte)'E': switch (data [1]) { case (byte)'C': if (data [2] == (byte)'S') // "notify.calibration.successful" { UnityEngine.Debug.Log("notify.calibration.successful"); PupilTools.CalibrationFinished(); } else if (data [2] == (byte)'F') // "notify.calibration.failed" { UnityEngine.Debug.Log("notify.calibration.failed"); PupilTools.CalibrationFailed(); } else { UnityEngine.Debug.Log("Unknown calibration ended event"); } break; case (byte)'G': if (data [2] == (byte)'2') { if (data [3] == (byte)'1') { //UnityEngine.Debug.Log("Left eye position received"); PupilTools.UpdateGazePostion(PupilSettings.gaze2DLeftEyeKey, FloatArrayFromPacket(data, 4)); } else if (data [3] == (byte)'0') { //UnityEngine.Debug.Log("Right eye position received"); PupilTools.UpdateGazePostion(PupilSettings.gaze2DRightEyeKey, FloatArrayFromPacket(data, 4)); } else if (data [3] == (byte)'2') { PupilTools.UpdateGazePostion(PupilSettings.gaze2DKey, FloatArrayFromPacket(data, 4)); } else { UnityEngine.Debug.Log("Unknown gaze 2d data"); } } else if (data [2] == (byte)'3') { PupilTools.UpdateGazePostion(PupilSettings.gaze3DKey, FloatArrayFromPacket(data, 4)); } else { UnityEngine.Debug.Log("Unknown gaze event"); } break; default: UnityEngine.Debug.Log("Unknown event"); break; } break; case 90: UnityEngine.Debug.Log("Start/stop calibration command"); if (data [1] == 1) { PupilTools.StartCalibration(); } else { PupilTools.StopCalibration(); } break; case 91: UnityEngine.Debug.Log("Forcing 2D calibration mode (Pupil version < 1 detected)"); PupilTools.CalibrationMode = Calibration.Mode._2D; break; case (byte)'R': if (PupilSettings.Instance.debug.printSampling) { Debug.Log("Reference points received"); } break; default: UnityEngine.Debug.Log(StringFromPacket(data)); break; } }