Log in or register to post comments

ITrackableEventHandler' could not be found

July 22, 2020 - 1:35am #1

Hello,

I'm relatively new to Unity and AR project and I'm stuck trying to dynamically add a 3D model to an Image Target. I have the following error and cannot understand where is the problem: error CS0246: The type or namespace name 'ITrackableEventHandler' could not be found (are you missing a using directive or an assembly reference?)

Here it is the code I'm using which's been taken from https://library.vuforia.com/content/vuforia-library/en/articles/Solution/Working-with-Vuforia-and-Unity.html#dynamically-add

 

using UnityEngine;

using Vuforia;

using System.Collections;

public class MyPrefabInstantiator : MonoBehaviour, ITrackableEventHandler {

  private TrackableBehaviour mTrackableBehaviour;

  public Transform myModelPrefab;

  // Use this for initialization

  void Start ()

  {

    mTrackableBehaviour = GetComponent<TrackableBehaviour>();

    if (mTrackableBehaviour) {

      mTrackableBehaviour.RegisterTrackableEventHandler(this);

    }

  }

  // Update is called once per frame

  void Update ()

  {

  }

  public void OnTrackableStateChanged(

    TrackableBehaviour.Status previousStatus,

    TrackableBehaviour.Status newStatus)

  {

    if (newStatus == TrackableBehaviour.Status.DETECTED ||

        newStatus == TrackableBehaviour.Status.TRACKED ||

        newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

    {

      OnTrackingFound();

    }

  }

  private void OnTrackingFound()

  {

    if (myModelPrefab != null)

    {

      Transform myModelTrf = GameObject.Instantiate(myModelPrefab) as Transform;

      myModelTrf.parent = mTrackableBehaviour.transform;

      myModelTrf.localPosition = new Vector3(0f, 0f, 0f);

      myModelTrf.localRotation = Quaternion.identity;

      myModelTrf.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

      myModelTrf.gameObject.active = true;

    }

  }

}

 

Could anyone help me? Thanks in advance!

ITrackableEventHandler' could not be found

July 29, 2020 - 5:10am #2

Hi,

Have you tried removing the ITrackableEventHandler from the script? or changing it to DefaultTrackableEventHandler

With 8.6.7 we made some changes, which were presented in our release notes : Refactored the way how Unity application code can register for Vuforia Engine events. Instead of implementing event handling interfaces, application scripts can now register for individual callbacks. See the VuforiaSamples for more details.

I also reported the issue to our documentation team to update the article.

Thank you.

Vuforia Engine Support

Log in or register to post comments