HoloLens Tutorial – Object Surface Observer

Last Updated: Apr 22, 2017

Tutorial Accomplishments

  1. Save Spatial Map for Use In Unity
  2. Object Surface Observer Setup

Save Spatial Map for Use In Unity

Next we will inject a fake spatial map when we run the project out of Unity, allowing us to test and debug directly in Unity without having to build the Visual Studio project.  First we need to save the spatial map of an actual room.  We’ll capture one of the rooms provided with the HoloLens Emulator.  Start by running your application in the emulator.  After the Application is running and you see spatial mapping open the HoloLens Web Portal.  The emulator provides a shortcut button in the toolbar to open up the web portal.  Click the Open Device Portal button in the emulator toolbar.


Click 3D View on the menu on the left side of the portal.  Click the Update Button under Spatial Mapping.  You should see a flat textured view of the room you are looking at in the emulator.


Click the Save button under Spatial Mapping, downloading a file called SpatialMapping.obj.


Object Surface Observer Setup

Move this file to the Assets folder of your Unity Project and rename it to “Room.obj”. Open the project in Unity 3D and you should now see the SpatialMapping mesh as an Asset. Select the Spatial Mapping node in the Hierarchy.  Click Add Component and Add “Object Surface Observer” from the HoloToolkit.  This component takes a Room Model and renders it as a Spatial Map that the Spatial Mapping Observer will use when running from Unity.  Set the Room Model to “Room.obj”.  Your project should now look like this:


Click Play in Unity. Click the Scene tab and you should now see your room rendered as a spatial map.  The ability to move around the room in the editor was added with the “HoloLens Camera” prefab in the Manual Gaze Control Script. Hold down the right mouse button and move the mouse cursor around until you see the mesh, use the WASD keys to move on the other axis.  The project now has spatial mapping in the Unity Editor, the HoloLens Emulator, and the HoloLens!

Tutorial Index

  Versions: Unity 2017.1.0p5 | MixedRealityToolkit-Unity v1.2017.1.0Visual Studio 2017 15.3.2
Unity 3D Project Creation How to create a HoloLens project in Unity 3D
Source Control Configure git for HoloLens / Unity work
Spatial Mapping How to spatial map a Room
Object Surface Observer Set up fake spatial map data for the Unity editor
TagAlongs and Billboarding   Tag along instructions to the user to force text on screen
Spatial Understanding Add spatial understanding to get play space detail
Finalizing Spatial Understanding Complete Spatial Understanding and Input Manager
Object Placement and Scaling Find valid locations for holograms in the play space
Hologram Management Manage the holograms you want to place in the world
Cursor and Voice Add a cursor and voice commands
Occlusion Add occlusion with the real world to your scene
Colliders and Rigidbodys Add Colliders and RigidBodys to your holograms

Leave a Reply