void Update() { if (Bridge == null || Bridge.Status != Comm.BridgeStatus.Connected) { return; } Reader.Update(); if (Reader.Status == AsyncTextureReaderStatus.Finished) { var data = Reader.GetData(); #if USE_COMPRESSED Task.Run(() => { lock (jpegArray) { int length = JpegEncoder.Encode(data, videoWidth, videoHeight, Reader.BytesPerPixel, JpegQuality, jpegArray); if (length > 0) { SendImage(jpegArray, length); } } }); #else SendImage(data, data.Length); #endif } if (Reader.Status != AsyncTextureReaderStatus.Reading && !ImageIsBeingSent) { if (manual) { if (Input.GetKeyDown(KeyCode.M)) { Reader.Start(); } } else { if (Time.time - lastTimePoint > 1.0f / sendingFPS) { lastTimePoint = Time.time; Reader.Start(); } } } }