public void LoadDataSet()
    {
        //code to change image target
        ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
        string        dataSetName   = Args.VENTANA_DATA_SET_NAME;
        DataSet       dataSet       = objectTracker.CreateDataSet();

        if (dataSet.Load(dataSetName, VuforiaUnity.StorageType.STORAGE_APPRESOURCE))
        {
            objectTracker.Stop();  // stop tracker so that we can add new dataset

            if (!objectTracker.ActivateDataSet(dataSet))
            {
                // Note: ImageTracker cannot have more than 1000 total targets activated
                Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>");
            }

            if (!objectTracker.Start())
            {
                Debug.Log("<color=yellow>Tracker Failed to Start.</color>");
            }

            int counter = 0;

            IEnumerable <TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours();
            ModelController mc = ModelController.Instance;
            foreach (TrackableBehaviour tb in tbs)
            {
                if (tb.name == "New Game Object")
                {
                    // change generic name to include trackable name
                    tb.gameObject.name = ++counter + tb.TrackableName;

                    // add additional script components for trackable
                    tb.gameObject.AddComponent <DefaultTrackableEventHandler>();
                    tb.gameObject.AddComponent <TurnOffBehaviour>();
                    GameObject           control = mc.GetPrefabWithId(Convert.ToInt32(tb.TrackableName, 16));
                    SpawnBehaviourScript spb     = tb.gameObject.AddComponent <SpawnBehaviourScript>();
                    spb.prefabObject = control;

                    if (control)
                    {
                        control.transform.SetParent(tb.gameObject.transform);
                        control.transform.localPosition = new Vector3(0f, 0f, 0.9f);
                        //control.transform.localRotation = Quaternion.identity * Quaternion.Euler(0, 180, 0);

                        control.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
                    }
                }
            }
        }
        else
        {
            Debug.LogError("<color=yellow>Failed to load dataset: '" + dataSetName + "'</color>");
        }
    }
예제 #2
0
    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren <Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren <Collider>(true);


        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }


        Debug.Log("VuMark of Type: " + GetVuMarkType(mTrackableBehaviour.VuMarkTarget) + " and Value: " + GetVuMarkString(mTrackableBehaviour.VuMarkTarget) + " found");

        ModelController mc       = ModelController.Instance;
        int             vuMarkId = Convert.ToInt32(GetVuMarkString(mTrackableBehaviour.VuMarkTarget), 16);

        control = null;
        try {
            control = mc.GetPrefabWithId(vuMarkId);
            if (control)
            {
                mTrackableBehaviour.transform.DestroyChildren();
                BaseVentanaController bvc = control.GetComponent <BaseVentanaController>();
                if (bvc)
                {
                    bvc.OnVumarkFound();
                    bvc.VentanaID = vuMarkId;
                }
                control.transform.SetParent(gameObject.transform);
                control.transform.localPosition = new Vector3(0f, 0f, 1.3f);
                control.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
                control.layer = 9;
                control.transform.localScale = new Vector3(.35f, .35f, .35f);

                SpawnBehaviourScript spb = control.gameObject.AddComponent <SpawnBehaviourScript>();
                spb.ControllerID    = vuMarkId;
                spb.shouldSpawn     = true;
                spb.scaleMultiplier = gameObject.transform.localScale;
            }
        } catch (Exception ex) {
            Debug.Log("[VuMarkEventHandler]: " + ex.Message);
        }
    }
예제 #3
0
 void OnEnable()
 {
     _spawn = target as SpawnBehaviourScript;
 }