2017-08-03 65 views
2

我在這裏如何註冊Unity3D中的事件ARToolKit 6 for OnMarkerFound?

https://github.com/artoolkit/ar6unity-wiki/wiki/Setting-Up-Your-First-ARToolKit-for-Unity-Scene

我需要使其觸發OnMarkerFound從標記事件註冊下面這個教程。下面的文章是過時

OnMarkerFound event not getting called - Unity3D ARToolKit

https://archive.artoolkit.org/documentation/doku.php?id=6_Unity:unity_scripts

我讀AAREventReceiver.cs文件,它說的東西很模糊:

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); 
} 

例如,我找不到任何地方IAREventReceiver。另外我在哪裏可以放arTrackedMarker.eventReceivers.add(this);

然後我看着我的AR Trackable對象註冊事件接收器。資產列表顯示none,儘管我有很多可用於註冊事件的GameObjects。

enter image description here

坦率地說,我不知道如何在V6這裏註冊事件。即使這個文檔是不準確的

https://archive.artoolkit.org/documentation/doku.php?id=6_Unity:unity_scripts

能否請你指出我嗎?謝謝。

回答

0

AAREventReceiver.cs裏面的文檔是錯誤的。它應該說:

「實現一個 AREventReceiver任何對象符合(...)」

說了這麼多。你需要編寫自己的腳本包含這些功能的實現:

public abstract void OnMarkerFound(ARTrackable marker); 
public abstract void OnMarkerTracked(ARTrackable marker); 
public abstract void OnMarkerLost(ARTrackable marker); 

,並使其延長 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 
    } 
} 

然後你可以選擇在EventReceivers名錄爲「元素0的MyEventReceiver '(指您的屏幕截圖)

我在這裏寫了一篇文章:http://augmentmy.world/migratetoartoolkit6 關於如何從ARToolKit5遷移到ARToolKit6

希望幫助

===編輯1:===

你不需要這個

arTrackedMarker.eventReceivers.add(this); 

了與ARToolKit6