QR / Barcode Scanner

It recognizes QR / Barcode.

Configuring the QR / Barcode Scene
Starting / Stopping the Scanner
Using the Scanning Information

Configuring the QR / Barcode Scene

  1. Install MAXST AR SDK for Unity.

  2. Create a new scene.

  3. Delete the Main Camera that exists by default and add 'Assets > MaxstAR > Prefabs > ARCamera' to the scene.

    codePrefab

    ※ If you build, you should add License Key to ARCamera.

  4. Create an empty object and add 'Assets > MaxstARSamples > Scripts > CodeScanSample' as a component.

    codeSample

  5. Add two Text, Button and in the GameObject's Inspector, drag and drop them.

    codeText

  6. Set the StartCodeScan () function in the Click event of the Button.

    codeBtn

  7. After playing, the result will be displayed in the Text by illuminating QR code or barcode on the camera.

Starting / Stopping the Scanner

To start / stop scanner, refer to the following code.

CodeScanSample.cs

void Update()
{
    ...
    TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_CODE_SCANNER);
    ...
}

void OnApplicationPause(bool pause)
{
    ...
    TrackerManager.GetInstance().StopTracker();
    ...
}

void OnDestroy()
{
    TrackerManager.GetInstance().StopTracker();
    TrackerManager.GetInstance().DestroyTracker();
}

Using the Scanning Information

When you illuminate the QR / Barcode, the code name is displayed on the screen. Refer to the following code to use the scanning information.

CodeScanSample.cs

void Update()
{
    ...
    IntPtr codeScanResultPtr = TrackerManager.GetInstance().GetCodeScanResult();
    if (codeScanResultPtr == IntPtr.Zero)
    {
        return;
    }
    string strCode = Marshal.PtrToStringAnsi(codeScanResultPtr);
    if (strCode != null && strCode.Length > 0)
    {
        targetText.text = strCode;
    }
}