Log in or register to post comments

a simple way to know if target is tracked.

June 10, 2012 - 11:55am #1

hi all

i want to edit the DefaultTrackableEventHandler.cs so it will contain boolean that will change when tracking is found=true \ lost=false...and a simple way to read its state from unity script every frame so i can base my app on it.

i need 2 lines of code:
1 - c# declaration.
2 - js calling line.

10 q all

a simple way to know if target is tracked.

July 4, 2018 - 3:23am #3

This works great. imageTargetName is name of image target object in the scene.

private bool isTrackingMarker(string imageTargetName)
        var imageTarget = GameObject.Find(imageTargetName);
        var trackable = imageTarget.GetComponent<TrackableBehaviour>();
        var status = trackable.CurrentStatus;
        return status == TrackableBehaviour.Status.TRACKED;

Re: a simple way to know if target is tracked.

June 13, 2012 - 3:30pm #2

Is this to relate the tracking state to an existing JS application? If so, have you tried defining your own event handler in JS and simply registering this w/ the TrackableBehaviour?


        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)

Otherwise you could define a public property on the existing DefaultTrackableEventHandler and poll that from your JS script.

In C#

bool mIsFound = false;

public bool IsFound{
   return mIsFound;


You'd set mIsFound to true or false within the OnTrackingLost & Found methods.

In JS, use a reference to the DefaultTrackableEventHandler.


var eventHandlerComponent : DefaultTrackableEventHandler = imageTarget.GetComponent(DefaultTrackableEventHandler );

if( eventHandlerComponent.IsFound ){
    // do something
Log in or register to post comments