Log in or register to post comments

Error ITrackableEventHandler

May 11, 2020 - 8:24pm #1

hello dears

I am trying to create the following scripts, with the ITrackableEventHandler, but it shows error CS0246 "Assets\Scripts\ShipRecoScript.cs(6,46): error CS0246: The type or namespace name 'ITrackableEventHandler' could not be found (are you missing a using directive or an assembly reference?)".

Version Unity: 2019.3.9f1 (64-bit)

Vuforia version: 9.1.7

 

 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

 

public class ShipRecoScript: MonoBehavior, ITrackableEventHandler

{

    private TrackableBehavior mTrackableBehavior;

 

    void Start ()

    {

        mTrackableBehaviour = GetComponent <TrackableBehaviour> ();

        if (mTrackableBehaviour)

        {

            mTrackableBehaviour.RegisterTrackableEventHandler (this);

        }

    }

    public void OnTrackableStateChanged (

                                    TrackableBehaviour.Status previousStatus,

                                    TrackableBehaviour.Status newStatus)

    {

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

            newStatus == TrackableBehaviour.Status.TRACKED ||

            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

        {

            // move the boat

            // Debug.Log ("move");

            MoveScript.current.MoveShip ();

        }

        else

        {

            // return the boat to its place

            MoveScript.current.ResetShip ();

            // Debug.Log ("return");

        }

    }

}

AttachmentSize
Image icon error CS0246.jpg149.03 KB

Error ITrackableEventHandler

November 19, 2020 - 8:48am #11

I'm having the exact same problem and I can't find a solution for the life of me

Error ITrackableEventHandler

November 2, 2020 - 11:11am #10

But what are you supposed to replace RegisterTrackableEventHandler with? 

Error ITrackableEventHandler

November 2, 2020 - 11:10am #9

Hi, 

Did you manage to solve this because I'm having the exact same problem. I have searched everywhere and can't find an answer. 

Error ITrackableEventHandler

October 22, 2020 - 11:17am #8

Hello, I am building an app and I actually found a code on the net to load scene after image target is detected but I  have error in this code. 

Assets\detect.cs(11,49): error CS0246: The type or namespace name 'ITrackableEventHandler' could not be found (are you missing a using directive or an assembly reference?)

Can you please help me ? 

 

using UnityEngine;

using UnityEngine.Events;

using Vuforia;

using System.Collections;

using System.Collections.Generic;

using UnityEngine.SceneManagement;

namespace Vuforia

{

    public class CustomsTrackableEventHandler : MonoBehaviour,

                                                ITrackableEventHandler

    {

        public ImageTargetBehaviour imageTarget;

        private ImageTargetBehaviour[] allImageSources;



        private TrackableBehaviour mTrackableBehaviour;



        void Start()

        {

            mTrackableBehaviour = GetComponent<TrackableBehaviour>();

            if (mTrackableBehaviour)

            {

                mTrackableBehaviour.RegisterTrackableEventHandler(this);

            }

            imageTarget = (ImageTargetBehaviour)gameObject.AddComponent<ImageTargetBehaviour>();

        }



        public void OnTrackableStateChanged(

                                        TrackableBehaviour.Status previousStatus,

                                        TrackableBehaviour.Status newStatus)

        {

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

                newStatus == TrackableBehaviour.Status.TRACKED ||

                newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

            {

                OnTrackingFound();

            }

            else

            {

                OnTrackingLost();

            }

        }

       



        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("Trackable " + mTrackableBehaviour.TrackableName + " found");



            //Go to Scene, IF detect a target

            if (mTrackableBehaviour.TrackableName == "Scene 1")

            {

                SceneManager.LoadScene("YourUnityProjectName 1");

            }

            if (mTrackableBehaviour.TrackableName == "Scene 2")

            {

                SceneManager.LoadScene("YourUnityProjectName 2");

            }



            if (mTrackableBehaviour.TrackableName == "Scene 3")

            {

                SceneManager.LoadScene("YourUnityProjectName 3");

            }

        }



        private void OnTrackingLost()

        {

            Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);

            Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);

            // Disable rendering:

            foreach (Renderer component in rendererComponents)

            {

                component.enabled = false;

            }

            foreach (Collider component in colliderComponents)

            {

                component.enabled = false;

            }

            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");

        }

    }

}

Error ITrackableEventHandler

September 17, 2020 - 7:47pm #7

New form on Unity 2019 and Vuforia 9.x.x

 

if (mTrackableBehaviour)

    mTrackableBehaviour.RegisterOnTrackableStatusChanged(OnTrackableStateChanged);

 

...

 

public void OnTrackableStateChanged(StatusChangeResult statusChangeResult)

  {

   if (statusChangeResult.NewStatus == Status.DETECTED ||

    statusChangeResult.NewStatus == Status.TRACKED ||

    statusChangeResult.NewStatus == Status.EXTENDED_TRACKED)

   {

    Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

    OnTrackingFound(mTrackableBehaviour.TrackableName);

   }

   else if (statusChangeResult.PreviousStatus == Status.TRACKED &&

    statusChangeResult.NewStatus == Status.NO_POSE)

   {

    Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");

    OnTrackingLost();

   }

   else

   {

    OnTrackingLost();

   }

  }

Error ITrackableEventHandler

June 28, 2020 - 6:09am #6

When i change i get an error like this

AttachmentSize
Image icon Ekran Resmi 2020-06-28 16.08.06.png101.13 KB

Error ITrackableEventHandler

May 21, 2020 - 3:31am #5

Hello Vuforia Team,

And what to do with RegisterTrackableEventHandler?

Error ITrackableEventHandler

May 20, 2020 - 12:51am #4

Hi,

Please change as follows:

public class ShipRecoScript: MonoBehavior, ITrackableEventHandler -> public class ShipRecoScript:DefaultTrackableEventHandler

Thank you.

Vuforia Engine Support

Edit: in 8.6.7 we changed our approach in regards to interfaces, info available 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.

Error ITrackableEventHandler

May 19, 2020 - 3:57pm #3

I still have the same problem. It does not work.

Error ITrackableEventHandler

May 12, 2020 - 2:12am #2

Hi,

Try changing the name to DefaultTrackableEventHandler.

Thank you.

Vuforia Engine Support

Log in or register to post comments