Log in or register to post comments

Observing Trackable Lost/Found events

March 6, 2018 - 10:14am #1

Let's say I have global UI element that previews info for the currently active trackable(s). How should I do this? NOTE: this is just an example, I need it for more complex use case

Yes, I know about StateManager and its GetActiveTrackableBehaviours() method, but I don't like the approach since I have to do check every frame instead of going more through observer pattern and execute callback only when there is trackable active, or new trackable found etc.




Observing Trackable Lost/Found events

March 9, 2018 - 9:41am #3

Hi there, thanks for the answer.

I'm already utilizing that interface, but I'm afraid it can not help here. The thing is, I want to monitor trackables on a GLOBAL level. I need component that will say: OK, new trackable(s) has been found, here it is, grab whatever info you need about it. And latter observers register to this event and react based on it.

Current workaround is to use GetActiveTrackableBehaviours() and write your own logic that recognises when the new trackable has been detected or the old one is lost and fire up some event. But that requires checking state for active trackables each frame which I don't like.

Another approach is to use class that is sort of (singleton) monitor and where all the trackables report themselves once they are detected/lost. A bit cleaner than previous one but still not clean enough.

I wonder if you (or whoever) have smarter and cleaner solution than the two i wrote above?

Observing Trackable Lost/Found events

March 7, 2018 - 10:43am #2

Hello Danilo,

The ITrackableEventHandler Interface contains the function OnTrackableStateChanged. If you have one of your classes implement this Interface and then register it with a TrackableBehaviour, it will get called any time that trackable's status has changed with both the previous and current TrackableBehaviour.Status. You can see an example of how this works in DefaultTrackableEventHandler.


Vuforia Support

Log in or register to post comments