I am trying to get some custom behaviour implemented using ARToolKit SDK on Unity3D.
According to the documentation here, the ARCamera uses the BroadcastMessage system to call OnMarkerFound(ARMarker marker) and OnMarkerLost(ARMarker marker) to notify when a marker is found or lost.
However, I cannot get these functions to fire at all. I have gone through the entire source code, added debug watches, the works... But these two events are not firing.
My script looks like this:
using UnityEngine;
using System.Collections;
public class CustomTrack : MonoBehaviour {
void OnMarkerFound(ARMarker marker){
Debug.Log("MARKER FOUND! WHEEEE!");
}
void OnMarkerLost(ARMarker marker){
Debug.Log("MARKER LOST! WHEEEE!");
}
void OnMarkerTracked(ARMarker marker){
Debug.Log("MARKER TRACKED! WHEEEE!");
}
}
I have seen several other people on forums, etc. facing similar problems so it would be nice to finally have a solution to this issue.
EDIT - Answer
Just to explain what I did to get this working, going by what @bleater said, I added the GameObject to the ARTrackedObject and then added my CustomScript to the GameObject. One mistake I was making was to attach the CustomScript to the ARMarkerScene. So, that worked. I hope this is useful to others as well.
