need direction

  • i’m trying to create an android ar application that shows real time data along with launching the 3d model of an object upon scanning of the barcode pasted on the object.
    for now i just want that the app loads the 3d model of an object upon scanning of its barcode.
  • for barcode scanning im using vuforia .
  • im new to unity so a bit lost on how to approach the problem. i was thinking of creating a dictionary something like this which maps the barcode value to its respective 3d model.

  • till now i only have only attached the script for barcode scanning in vuforia


9818919--1411161--upload_2024-5-7_9-54-32.png

What do you mean by launching the 3d model?
You could use a ScriptableObject.

The scriptable object could contain a list of entries, each entry has a unique barcode id, and a reference to the prefab in the assets folder.

public class BarcodeSO: ScriptableObject
{
    [Serializable]
    public class BarcodeEntry
    {
        public int barcodeNumber;
        public GameObject modelPrefab;
    }

    public BarcodeEntry[] entries;

    public GameObject GetModelPrefab (int barcodeNumber)
    {        
        var entry = entries.ToList<BarcodeEntry> ().Find ((x => x.barcodeNumber == barcodeNumber));
        return entry.modelPrefab;
    }
}

Then to search and create an instance of the model in the scene:

var prefab = barcodeSO.GetModelPrefab (barcodeNumber);
var modelInstance = Instantiate (prefab);