Creating HoloLens applications is just cool! But connecting them to services in the Cloud makes it even cooler. Think of provisioning information on real-life objects or straw through Cloud data like persons, related contacts, documents and other stuff. This allows you to build rich applications containing information you normally process in a 2D world  like your browsers. By extending it to a 3D world, you are able to process the data in a completely different way. Think of creating teams of people within your organization and group them based on specialties, getting a more clear inside view of your site structure in SharePoint or have a 3D model of the Microsoft Graph entities related objects.

This article is split into several posts which together describes how to connect your HoloLens App with the Microsoft Graph.

  1. Introduction (this post)
  2. Register, Connect and get data
  3. Reference your class library in Unity
  4. Create a scene in Unity and connect your library

Introduction

This blog post explains how you can interact with Microsoft Graph from a HoloLens app and overcome all the difficulties building solutions around it.

Capture

In this example i used a curved view displaying the Teams and People from my demo tenant by accessing the Microsoft Graph API. Don’t mind the Halloween balloons in the back 😉

Getting back into reality

The first thing you need to understand is that building applications for HoloLens normally is done with Unity and Visual Studio. The second thing you need to understand is that building an App for HoloLens is almost the same as building an UWP (Universal Windows App). Unity itself is a single threaded application. While they support a kind of multi threading by using the function StartCoroutine, it is not the same. It is a kind of simulation of multi threading. Because we are going to access services in the Cloud, we need to consider that there will be latency when calling methods. To prevent Holograms hanging we need to use asynchronous functions, something which is not supported by Unity. Secondly because we are developing a UWP app, we need to consider that not all NuGet packages are available. UWP is based on using certain Windows 10 SDK apis. That means that we are using .NET core libraries. There are not many NuGet packages available to create easy (click and go) solutions for connecting to the Cloud.

Application Lifecycle

Before we start explaining how we integrate a solution which connect to the Cloud, we need to understand the process of developing an application for HoloLens. Normally one use Unity to build your scene. The scene contains hologram objects attached with code running in the holograms context. As soon as you have build your scenery, it allows you to create an Visual Studio solution with the holograms and other stuff as assets. That Visual Studio solution is used to create the UWP application and deploys it to the HoloLens. As soon as something is changing on a Unity level (think of changes in your scene or holograms) we need to recreate the build of the Visual Studio solution. Unity compiles against its own SDK libraries. If you changed code in Visual Studio in the mean time like adding asynchronous code, it will not compile. You need to add precompiler directives and move stuff to separate libraries which you include from your project. An example of the use of precompiler directives can be found here.

Architecture of the application

When building applications which use a lot of packages and functionality which is not directly supported it is always smart to move that to a separate class library which you include in your project. Otherwise you will need to use a lot of precompiler directives to exclude code. And in some cases it is not even possible anymore in the way how the calls are integrated in your application process.

The architecture of the application is rather simple. For this example i have been using the following:

  • Solution containing the three projects generated by Unity
    • Assembly-CSharp (Universal Windows)
    • Assembly-CSharp-firstpass (Universal Windows)
    • OfficeSketch (Universal Windows)
  • OfficeGraphLibrary – Class Library (Universal Windows)
  • TestApp – App (Universal Windows)

The three projects are generated by Unity when building the Visual Studio application for my HoloLens app. The OfficeGraphLibrary class library contains the functionality to connect to Microsoft Graph and retrieve data based on calls to the API. It contains asynchronous calls and uses specific libraries for authentication and the Microsoft Graph which i don’t want to have directly in my solution. From within the HoloLens app i will be doing some asynchronous calls which are contained within precompiler directives to ensure that Unity can still compile the code when we have changes. The TestApp is used to make my life easier. Instead of deploying each change in the API calls to the HoloLens, i’m able to test my application on a desktop. It is also possible to test within Unity but i will explain this later.

Previous articleSet the active scene of a HoloLens project in Unity
Next articleConnecting your HoloLens app with Microsoft Graph – Register, connect and get data – 2 of 4
A professional which inspires, motivates and educates businesses on how to leverage emerging technologies using Virtual, Augmented and Mixed Reality in their journey to digital innovation. He has a strong background on SharePoint, Office 365 and Microsoft Azure and is working with machine learning, artificial intelligence and cognitive services. Primarily focused on manufacturing, construction, industry, logistics and maritime/offshore, his goal is helping businesses to achieve more on creating, improving, smartening and shortening of business processes by using services, apps and devices. Furthermore, he engages in speaking, blogging and is organizer of events like the Mixed Reality User Group, Mixed Reality Talk @ VR, SP&C and the Global AI/MR Bootcamp. With more than 20 years of IT Business experience, acting in different roles like solution architect, he believes the future is just starting! Highly experienced in all realities, HoloLens and other devices, User experiences on devices and connecting the world to the cloud will help him to shape that future!

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here