"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Working VuMark Unity Script

I have been working on some AR training and found a lack of usable VuMark scripts. While I am not a programmer, I put something together that works for a proof of concept I am working on, and figured I should post it here for anyone to use and hopefully save you some time.

The script goes onto an empty game object which I will call the "PickerObject" that is a child of the VuMark. Empty game objects are made with the exact VuMark Id names (I made this using numeric VuMark Ids)  These objects are parented to the PickerObject . Anything you then parent to the empty game objects named with the VuMark Ids will become active when the VuMark Id is found. 

Image removed.

using System.Collections; using System.Collections.Generic; using UnityEngine; using Vuforia; /* *******Trigger a scene with Matching Vumark Id***********

Place script on a empty game object that is a child of the VuMark. Create empty game objects with matching VuMark Instance Ids. inside of those empty game objects put in what you want to be active when the VuMark Id id tracked.

1. Vumark     a. Empty game object with this script (child of VuMark)         i. Empty game object- named same as VuMark Id (child of empty game object with script)             1. Stuff you want to show up whe the Vumark ID is found (Child of empty game object with VuMark Id name)         i. Empty game object- named same as VuMark Id (child of empty game object with script)             1. Stuff you want to show up whe the Vumark ID is found (Child of empty game object with VuMark Id name)     You can make as many as you want. The script will look down the list     and if it finds a matching VuMarkId and a child of the object the script is on,     it will make that object active, if not all objects stay inactive

    If you find any errors please email me

    Rich     richfiore01@gmail.com */ public class VuMarkIdToScene : MonoBehaviour {

    public VuMarkTarget vumark;     private VuMarkManager mVuMarkManager;

    void Start ()         {             mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager();         }

    void Update ()         {         foreach (var bhvr in mVuMarkManager.GetActiveBehaviours())         {             vumark = bhvr.VuMarkTarget;             var VuId = vumark.InstanceId;             print ("Found ID number " + VuId);

            foreach (Transform child in transform)                 {            

                if (child.name == VuId.ToString())                     {                     child.gameObject.SetActive (true);                     }

                else                     {                     child.gameObject.SetActive(false);                     }

                }

        }

    } }

Thanks a lot for posting this, it has been difficult to find resources outside of the official core documentation which can be difficult to get working.

Sorry if this is too much if this is a bit of a beginner question, but I'm new to Vuforia, Unity, and Scripting.

Thanks for sharing the script @f10r3!
In my case, it worked well only for one image tracked at a time.
When two VuMarks with different IDs were tracked at the same time, both were given the same ID when using the script.

Thanks a lot for this script ! It works much better than the one I have.

I'm also trying to track 2 vumarks simultaneously but it shows the same vumark ID. But works fine when trying to detect just one.

Would you have a script that enables this ?