"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

Can't get TrackableBehaviour component

Hi, folks, 

 

I wanted to capture the events when the ImageTarget is detected or lost.

I copied the default event hander as:

public class TrackedEvent : MonoBehaviour, ITrackableEventHandler { ....   protected virtual void Start()     {         mTrackableBehaviour = GetComponent<TrackableBehaviour>();         if (mTrackableBehaviour){             mTrackableBehaviour.RegisterTrackableEventHandler(this);             Debug.Log("handler:true ");         }else{             Debug.Log("handler: false.");         }     }     .... }

I attached the script to an empty game object.

In the Start() function, it always logged "false", which means the GetComponent returned null, so  the   events can not be captured.   How can I fix this  ?

 

Thank you very much. 

 

Alex