Wire capture button to UDT capture event

To enable user defined target (UDT) events, we need to add Vuforia's UDT Event Handler component to the UserDefinedTargetBuilder:

  1. With UserDefinedTargetBuilder selected in Hierarchy, Add Component UDT Event Handler.
  2. Drag the UserDefinedTarget from Hierarchy onto the Image Target Template slot.

Now we can tell the button that OnClick events should call the BuildNewTarget() function:

  1. In the Capture Target Button's Inspector, press the + on OnClick().
  2. Drag the UserDefinedTargetBuilder onto the Object slot.
  3. And set the function to BuildNewTarget().

The following screenshot shows the Capture Button OnClick setup for the UDT Event Handler:

Save your work. Now when you press Play, point your webcam at a target and press Capture. Whenever the camera sees and recognizes that camera view, it will render the AR content. For now, it's the cube.

In the following screenshot, I am testing the app with a toy truck on my desk (a real car wouldn't fit in my office). I captured its tire as the target.

Now let's try it with the AR View too:

  1. Re-enable the Content Scroll View object.

You'll notice that the Capture Target button is still visible.

  1. Move the AR Prompt panel up in the Hierarchy so it's just under the Nav Panel, as shown in the following screenshot:

Now press Play. Then press AR View and press Capture Target. Voila!

You might want to disable Content Scroll View again as we proceed.

More experienced developers can open the UDTEventHandler script (click the gear on the component and choose Edit Script) to peruse the script, read through it, and understand fully what's going on.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.238.20