Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Setting the ImageTarget name as a variable?

Discussion in 'Vuforia' started by malagon, Aug 8, 2018.

  1. malagon

    malagon

    Joined:
    May 12, 2015
    Posts:
    2
    Hi,

    I have a slight problem that is driving me mad. What I want to do is to get the name of the currently tracked ImageTarget set to a variable so I can call it from a function.

    The scenario is like this: I have a set of different products that are represented by their individual qr-codes as ImageTargets. When any of these qr-codes are found, a set of buttons pops up. One button will show that products information and when pressed, will call a function that will do a search from a database:

    GetProductInfo()
    QRCode = .....
    .
    .
    ..... string query = "SELECT * from Product WHERE QRCode =" + QRCode;

    I've tried using:
    TrackableBehaviour TB;
    TB = GetComponent<TrackableBehaviour>();

    and setting the variable QRCode inside the function as following:
    QRCode = TB.TrackableName;

    But its not working.
    Any help would be appreciated.
     
  2. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    266
    Hello,

    An ImageTarget name is populated as part of the Target Manager workflow. This is where you upload an image to Vuforia's developer portal, and eventually download a device database that contains N number of ImageTargets (or other trackable types).

    Have you been uploading QR codes to the Target Manager like this?

    Thanks,
    Vuforia Engine Support
     
  3. malagon

    malagon

    Joined:
    May 12, 2015
    Posts:
    2
    Yes I have a set of Targets uploaded to the Target Manager. They are basically different QR-Codes for each product. These targets are then set as ImageTargets in Unity, and I want to be able to do a database search based on the different Target names.
     
  4. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    266
    Hello @malagon ,

    Thanks for confirming. This API *should* be working.

    Please review the DefaultTrackableEventHandler.cs from our Core samples. It demonstrates how to retrieve the trackable name. Let me know if that doesn't work and we'll investigate further.

    Thanks,
    Vuforia Engine Support