Topic locked

DefaultTrackableEventHandler Added at Runtime

June 24, 2021 - 8:24am #1

Hello all, Im currently trying to make a bunch of image targets dynamically via loading a Vuforia Database at runtime. All is going well, Im able to load and find all the imageTargetBehaviours no problem. But i'm running into a brick wall I really wasnt expecting.

Im adding the DefaultTrackableEventHandler to the ImageTargetBehaviour gameObjects after loading in the database, just like what is done in the vuforia library examples. Everything goes well until I actually try to subscribe to the DefaultTrackableEventHandler's OnTargetFound and OnTargetLost events, no matter how hard I try, I get errors saying that the object reference is null. If a check the DefaultTrackableEventHanlder right before subscribing to it I can see its not null so I'm getting very confused.

I tried a second use case where I just had a empty scene with a single gameObject. If add DefaultTrackableEventHandler to the object in editor, and than try to subscribe to its OnTargetFound and OnTargetLost events, I have no issues.

However if I remove the trackableEventHandler from editor and than add it via script at runtime, I run into the exact same issue where is tells me the object is null when I try to subscribe to the events.

I'm at a loss, I have wasted way more hours than I'd like to admit trying to get this to work, any help would be appreciated im currently walled.


Im using Unity Editor version 2021.1.6f and Vuforia 9.8.

Topic locked