Hi, i’m doing an application using Qrcode reader (Vuforia plugin). Well, the Qr code reader is open a scene, then when i try to go back to the camera, just to read another qr code, in 2 or 3 seconds, the application reload the previously scene. How can i fix it?
Here is the code:
`using UnityEngine;
using System;
using System.Collections;
using Vuforia;
using System.Threading;
using ZXing;
using ZXing.QrCode;
using ZXing.Common;
using UnityEngine.SceneManagement;
[AddComponentMenu(“System/VuforiaScanner”)]
public class QrCodeReader : MonoBehaviour {
%|-90361675_1|%
private BarcodeReader barCodeReader;
%|1266818644_3|%
%|-189217523_4|%
barCodeReader = new BarcodeReader();
StartCoroutine(InitializeCamera());
}
private IEnumerator InitializeCamera()
%|1284009173_9|%
// Waiting a little seem to avoid the Vuforia’s crashes.
%|-685522107_11|%
%|1429767178_12|%
%|1607410037_13|%
var isAutoFocus = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
%|-1759573269_15|%
{
CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
%|1732712364_18|%
cameraInitialized = true;
StartCoroutine(“AtualizaCamera”);
}
IEnumerator UpdateCamera() {
yield return new WaitForSeconds(0.5f);
%|348993817_24|%
%|48031002_25|%
%|2130470230_26|%
}
}
%|1651838712_29|%
if (cameraInitialized)
%|-1357344353_31|%
try
%|-1960225348_33|%
var cameraFeed = CameraDevice.Instance.GetCameraImage(Image.PIXEL_FORMAT.RGB888);
if (cameraFeed == null)
{
return;
}
var data = barCodeReader.Decode(cameraFeed.Pixels, cameraFeed.BufferWidth, cameraFeed.BufferHeight, RGBLuminanceSource.BitmapFormat.RGB24);
if (data != null)
%|1457202205_41|%
if (data.ToString() == "panel")
{
%|1253775661_44|%
%|-1540680839_45|%
%|1332395290_46|%
%|1317861176_47|%
catch (Exception e)
{
%|769398355_50|%
}
}
`