Здравствуйте, нашёл готовый код для сканирования Qr-code, но он лагает вся проблема в try{} но я не знаю как её решить,помогите! Спасибо!

using UnityEngine;
using UnityEngine.UI;
using ZXing;

public class QR_WebCam : MonoBehaviour
{
    private WebCamTexture camTexture;
    private Rect screenRect;
    public Text Qr_Code_Value;
    void Start()
    {
        screenRect = new Rect(0, 0, Screen.width, Screen.height);
        camTexture = new WebCamTexture();
        camTexture.requestedHeight = Screen.height;
        camTexture.requestedWidth = Screen.width;
        if (camTexture != null)
        {
            camTexture.Play();
        }
    }

    void onGUI()
    {
        // drawing the camera on screen
        GUI.DrawTexture(screenRect, camTexture, ScaleMode.ScaleToFit);
        // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake
        try
        {
            IBarcodeReader barcodeReader = new BarcodeReader();
            // decode the current frame
            var result = barcodeReader.Decode(camTexture.GetPixels32(), camTexture.width, camTexture.height);
            if (result != null)
            {
                Qr_Code_Value.GetComponent<Text>().text = result.Text;
            }
        }
        catch (Exception ex) { Debug.LogWarning(ex.Message); }
    }

} ```

Ответы (1 шт):

Автор решения: Алексей

Можешь использовать конкретный декодер для QRCode. Насколько я помню, Zxing внутри перебирает все возможные штрихкоды. Так будет быстрее. Поищи по namespace, должен быть для него декодер и энкодер

→ Ссылка