/// <summary> /// Start a scan and wait for the callback (wait 1s after a scan success to avoid scanning multiple time the same element) /// </summary> private void StartScanner() { BarcodeScanner.Scan((barCodeType, barCodeValue) => { if (TextHeader.text.Length > 250) { TextHeader.text = ""; } TextHeader.text += "Found: " + barCodeValue + "\n"; MD5 md5Hasher = MD5.Create(); var hashed = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(barCodeValue)); scannedValue = BitConverter.ToInt32(hashed, 0); Image = null; BarcodeScanner.Destroy(); BarcodeScanner = null; // Feedback AudioSource.PlayClipAtPoint(Audio, Camera.main.transform.position); #if UNITY_ANDROID || UNITY_IOS Handheld.Vibrate(); #endif }); }
/// <summary> /// This coroutine is used because of a bug with unity (http://forum.unity3d.com/threads/closing-scene-with-active-webcamtexture-crashes-on-android-solved.363566/) /// Trying to stop the camera in OnDestroy provoke random crash on Android /// </summary> /// <param name="callback"></param> /// <returns></returns> public IEnumerator StopCamera(Action callback) { // Stop Scanning if (BarcodeScanner != null) { Image = null; BarcodeScanner.Destroy(); BarcodeScanner = null; } // Wait a bit yield return(new WaitForSeconds(0.1f)); callback.Invoke(); }
private IEnumerator StopCamera(Action callback) { outputImage = null; scanner.Destroy(); scanner = null; yield return(new WaitForSeconds(0.1f)); callback.Invoke(); }
public IEnumerator StopCamera() { // Stop Scanning Image = null; BarcodeScanner.Destroy(); BarcodeScanner = null; // Wait a bit yield return(new WaitForSeconds(0.1f)); }
/// <summary> /// This coroutine is used because of a bug with unity (http://forum.unity3d.com/threads/closing-scene-with-active-webcamtexture-crashes-on-android-solved.363566/) /// Trying to stop the camera in OnDestroy provoke random crash on Android /// </summary> /// <param name="callback"></param> /// <returns></returns> public IEnumerator StopCamera(Action callback) { // Stop Scanning UIEngine.Get <UICamera> ().CameraImage = null; BarcodeScanner.Destroy(); BarcodeScanner = null; // Wait a bit yield return(new WaitForSeconds(0.1f)); callback.Invoke(); }
private void StopScan() { // Stop Scanning scanImage.gameObject.SetActive(IsScan = false); if (BarcodeScanner != null) { BarcodeScanner.Destroy(); } BarcodeScanner = null; RestartTime = 0; }
private IEnumerator DestroyScanner(Action callback) { // Stop Scanning Image = null; if (BarcodeScanner != null) { if (BarcodeScanner.Camera.IsPlaying()) { BarcodeScanner.Camera.Stop(); } BarcodeScanner.Camera.Destroy(); BarcodeScanner.Destroy(); BarcodeScanner = null; } // Wait a bit yield return(new WaitForSeconds(0.1f)); }