Log in or register to post comments

Can't get TrackableBehaviour component

May 30, 2019 - 3:01pm #1

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 

Log in or register to post comments