Reputation: 19896
I am following this tutorial here
https://github.com/artoolkit/ar6unity-wiki/wiki/Setting-Up-Your-First-ARToolKit-for-Unity-Scene
I need to register for event from the Marker so that it triggers OnMarkerFound. The below post is out of date
OnMarkerFound event not getting called - Unity3D ARToolKit
https://archive.artoolkit.org/documentation/doku.php?id=6_Unity:unity_scripts
I read AAREventReceiver.cs file and it said things very vague:
using UnityEngine;
/// <summary>
/// Any object that implements IAREventReceiver is eligable to register for tracking
/// events from any ARTrackable object.
/// To register with an ARTrackable:
/// arTrackedMarker.eventReceivers.add(this);
/// </summary>
///
public abstract class AAREventReceiver : MonoBehaviour {
public abstract void OnMarkerFound(ARTrackable marker);
public abstract void OnMarkerTracked(ARTrackable marker);
public abstract void OnMarkerLost(ARTrackable marker);
}
For example, I cannot find IAREventReceiver
anywhere. Also where do I put arTrackedMarker.eventReceivers.add(this);
?
Then I looked in my AR Trackable object to register the event receivers. The asset list showing none
although I have many GameObjects available to register the event.
Frankly, I don't know how to register the event in v6 here. Even this doc is not accurate
https://archive.artoolkit.org/documentation/doku.php?id=6_Unity:unity_scripts
Can you please point me out? Thanks.
Upvotes: 2
Views: 431
Reputation: 1157
the documentation inside AAREventReceiver.cs is wrong. It should say:
"Any object that implements AAREventReceiver is eligible (...)"
Having said that. You need to write your own script that contains these function implementations:
public abstract void OnMarkerFound(ARTrackable marker);
public abstract void OnMarkerTracked(ARTrackable marker);
public abstract void OnMarkerLost(ARTrackable marker);
And make it extend AAREventReceiver:
public class MyEventReceiver : AAREventReceiver {
public abstract void OnMarkerFound(ARTrackable marker){
//log OnMarkerFound
}
public abstract void OnMarkerTracked(ARTrackable marker){
//log OnMarkerTracked
}
public abstract void OnMarkerLost(ARTrackable marker){
//log OnMarkerLost
}
}
Then you can select the MyEventReceiver in the EventReceivers-List as 'Element 0' (referring to your screenshot)
I wrote an article here: http://augmentmy.world/migratetoartoolkit6 on how to migrate from ARToolKit5 to ARToolKit6
Hope that helps
===Edit 1: ===
You don't need this
arTrackedMarker.eventReceivers.add(this);
anymore with ARToolKit6
Upvotes: 0