Unity How-go Guide: Depth Perception

These instructions will get you up and running with a simple point cloud application in Unity, intended for Unity developers of any experience level. You'll build a simple scene in Unity, import the Tango functionality, and attach prefabs that get the depth sensor data and display it as you move the Tango device around.

For more experienced Unity developers, you may also want to review the code samples in GitHub and the SDK Reference Documentation.

Preliminary steps

  1. If you haven't set up your computer to develop with Tango in Unity yet, see Getting Started With Unity.

  2. Go to the Setup for All Unity Tango Apps page and perform the basic setup operations on that page. When you have finished, return to this page and continue on with the steps below.

Add prefabs to your Hierarchy

You'll need the Tango Point Cloud and Tango Camera prefabs.

If you're not familiar with Prefabs, see the Unity documentation on them.

  1. In the Project panel, click TangoPrefabs to view the contents of that folder.
  2. Drag the Tango Point Cloud prefab (rainbow box icon) into the Hierarchy panel.
  3. Drag the Tango Camera prefab into the Hierarchy panel.

Enable depth in the Tango Manager

  1. In the Hierarchy panel, select the Tango Manager prefab.
  2. In the Inspector, select Enable Depth in the Tango Application (Script) component.

Enable mesh rendering to update the point cloud

  1. In the Hierarchy panel, select the Tango Point Cloud prefab.
  2. In the Inspector, select the checkbox to the left of Mesh Renderer.
  3. In the Tango Point Cloud (Script) component, select Update Points Mesh.

Build and run your project

  1. On the File menu, click Build and Run.
  2. In the Build Settings dialog, click Build and Run.
  3. In the Build Android dialog, enter a name in the Save As field, and then click Save.

After the build bar clears, Unity launches your application on the Project Tango device. Walk around with your device, and see it render the Point Cloud of what it sees!

Enviar comentarios sobre…