Launching a Unity Project in HoloLens

By in
No comments

This video follows from the previous one created for the TechRewards challenge. This time we take that same project and discover what modifications are needed to open the same project in the Unity for HoloLens version, as well as deploy it as a 3D app to the emulator.

Launching the TechRewards Unity Challenge Project in the HoloLens

Although the audio quality is still weak (I promise the next video will be better!), I was able to leverage the Azure Media Services platform to actually transcribe the text. I’ve embedded this transcript both in the YouTube video, as well as copied below. If you would like to take advantage of this feature for yourself, be sure to check out this awesome post from fellow Falafel developer Carey Payette: Using Azure Media Services to Encode, Host, and Transcribe Video I’ll be updating the previous videos with this same feature, and running all future videos through it as well going forward. As always I hope this was helpful, and thanks for watching!

Video Transcription

00:08.570 --> 00:11.810 Hello, again, everyone this is Josh Morales from Falafel Software and welcome to the Video Transcription
00:11.810 --> 00:15.130 follow-up video for the TechRewards challenge in which 
00:15.130 --> 00:19.670 I open the project in the Unity for HoloLens version 
00:19.670 --> 00:23.510 and attempt to run the same application from the previous video 
00:23.510 --> 00:25.770 with the two cubes 
00:25.770 --> 00:30.660 attacking each other in the HoloLens emulator. Now I'll admit 
00:30.660 --> 00:33.760 that I did actually run through this already off screen. 
00:34.850 --> 00:40.290 But, I'm hoping they'll be able to reproduce the results again for the video 
00:40.290 --> 00:43.060 and I'll walk through some of the things that I did encounter and how I 
00:43.060 --> 00:47.930 overcame them so that hopefully they'll still be useful to anybody watching who may be 
00:47.930 --> 00:52.830 attempting to do something similar or may just be curious about the relationship between the original Unity and 
00:52.830 --> 00:55.310 the HoloLens version so... 
00:55.310 --> 00:56.530 what I'm going to do is I'm gonna start of the start off 
00:56.530 --> 01:01.240 by opening the same project I created for that challenge video. 
01:01.240 --> 01:06.990 Here and you'll notice that I am running the unity HoloLens preview, 
01:06.990 --> 01:13.190 so I'm going to go ahead and open that same project here and it tells me that it was opened with a different version and 
01:13.190 --> 01:18.050 opening it in an older version obviously is not supported but we're not doing that here so it is going 
01:18.050 --> 01:22.780 to likely re import everything which it does so I'm gonna let that run. 
01:22.780 --> 01:27.060 And so here we are. So we'll see that I actually do have the same layout and 
01:27.060 --> 01:31.980 the same output we got to cubes floating in the skybox just as we did 
01:31.980 --> 01:36.140 before if we hit play we should get a similar result of the cube launching 
01:36.140 --> 01:39.380 toward the player. So out-of-the-box the original project works as-is; 
01:39.380 --> 01:42.630 we don't really need to do anything. So... 
01:43.860 --> 01:46.070 The last time that I did this I actually started 
01:47.310 --> 01:52.130 by deleting the main camera and then importing 
01:53.390 --> 01:57.420 All of the assets from the HoloLens toolkit 
01:58.580 --> 02:02.900 that I had previously shown. This is something that's available on github. 
02:02.900 --> 02:05.210 It does include a number of prefabs 
02:06.340 --> 02:12.040 specifically a camera that is configured already to run in the HoloLens 
02:12.040 --> 02:18.030 representing the user wearing the HoloLens so that the camera is the field of view of the device itself. 
02:18.030 --> 02:20.320 Now it turns out that 
02:20.320 --> 02:24.190 although is helpful, and probably certainly recommended 
02:24.190 --> 02:27.480 it isn't strictly necessary in order to have 
02:27.480 --> 02:31.020 your Unity application run in HoloLens. So while I did do that 
02:31.020 --> 02:35.060 in the first-run through this, I actually want to go ahead and show 
02:35.060 --> 02:35.970 What I learned by 
02:37.830 --> 02:51.470 going to the HoloLens documentation. 
02:51.470 --> 02:55.090 And actually what I really want to do is go to the section 
02:55.090 --> 02:59.580 in the dev center for holographic and navigate down to the holographic 
02:59.580 --> 03:03.080 academy which has a whole bunch of resources 
03:03.080 --> 03:07.770 that go actually further, at least from what I've been able to find, so that 
03:07.770 --> 03:12.710 documentation specifically this holograms one hundred, gives a excellent 
03:12.710 --> 03:17.260 walk-through of setting up your environment in Unity for the HoloLens, which 
03:17.260 --> 03:21.840 I'll dive further into in a little bit to solve another problem that I had... 
03:21.840 --> 03:25.440 But first things first, it does actually show you 
03:25.440 --> 03:29.620 how to setup camera specifically by 
03:29.620 --> 03:34.060 changing the clear flags in the drop-down to the main camera in the inspector to 
03:34.060 --> 03:36.880 a solid color for black. 
03:36.880 --> 03:41.560 And, that's actually probably the most important thing you need to do and, 
03:41.560 --> 03:46.160 really, to change existing project to work with HoloLens we just need to modify the camera 
03:46.160 --> 03:51.150 and it states to place it at origin, so I'm going to go ahead and do that, which means I probably have to move 
03:51.150 --> 03:56.130 my box around... but that's okay. I'm going to take the enemy box 
03:56.130 --> 03:59.320 and pull him 
03:59.320 --> 04:00.140 this way... 
04:01.440 --> 04:04.170 And, let's go ahead and take the player 
04:04.170 --> 04:08.250 box and pull him a bit further out, so that he'll hopefully be in 
04:08.250 --> 04:12.650 field of view. All right, so most importantly the cameras... So we need to change from skybox 
04:12.650 --> 04:17.230 to solid color and change the background to black. 
04:17.230 --> 04:20.750 So, now this looks a lot more like the HoloLens experience 
04:20.750 --> 04:25.840 that we had seen previously in our "Hello World" project. Namely, that the black represents everything that you 
04:25.840 --> 04:29.320 see through the device and the 
04:29.320 --> 04:34.320 rendered objects are now the only thing that'll actually be projected into that world. 
04:35.340 --> 04:38.100 So we'll go ahead and save this... And here's where I 
04:38.100 --> 04:43.730 had the next trouble... and which I wasn't quite sure how to configure this project to 
04:43.730 --> 04:48.700 properly launch in the HoloLens. If you leave the project in 
04:48.700 --> 04:54.340 its default state from the original Unity in the build settings here... So if I select Windows 
04:54.340 --> 04:58.940 Store we'll switch to that platform and we'll change to Universal 10, just like we would 
04:58.940 --> 05:00.680 have done for a regular HoloLens project. 
05:01.750 --> 05:10.320 When we save this, and build it, I'm going to go ahead and do that now; I'll pause while it does that... 
05:10.320 --> 05:17.380 Oh that's goes in the App folder... 
05:17.380 --> 05:23.800 Okay so, that's built and now I'll open this project in Visual Studio. 
05:23.800 --> 05:27.160 And as always the first thing we want to check to make sure the 
05:27.160 --> 05:34.490 platforms is x86 and that the device selected is the HoloLens. 
05:34.490 --> 05:38.320 So I'll go ahead and build the solution, 
05:38.320 --> 05:42.750 and then run it in the emulator to show what happens when we 
05:42.750 --> 05:46.590 run this project without making any changes to the 
05:46.590 --> 05:54.750 build configuration. So I'll go ahead and pause this while the emulator fires up. 
05:54.750 --> 05:57.380 Okay, so the HoloLens has fired up... 
05:57.380 --> 05:59.020 Now we'll just wait for the app to deploy... 
06:00.200 --> 06:05.170 and we'll see what this original Unity app that we didn't really modify other than the camera looks like when 
06:05.170 --> 06:12.720 it's run in the HoloLens. 
06:12.720 --> 06:13.900 So as you can see 
06:13.900 --> 06:18.640 it fired up inside of a window rather than taking the full 
06:18.640 --> 06:23.390 spectrum of the emulator and rendering in the 3D world. 
06:23.390 --> 06:25.410 So it's rendered it as a 2D application, 
06:26.770 --> 06:29.480 inside as if it was just any XAML app that you 
06:29.480 --> 06:39.740 can pin to the wall or have it follow you around. Let me go ahead and place this here. 
06:39.740 --> 06:44.050 Once we do that we see everything kinda goes a little haywire... Anyway so this is actually 
06:44.050 --> 06:49.740 expected now that I really think about it because 
06:49.740 --> 06:55.200 we're running it as a Unity app that was not really designed to run on a HoloLens and under the configuration of 
06:55.200 --> 07:00.050 the HoloLens and it's just doing the best it can do. So that makes total sense. But I 
07:00.050 --> 07:04.640 wasn't quite sure what I needed to do to fix it. So let me go ahead 
07:04.640 --> 07:10.220 and show you that by going back ... well actually let me go ahead and close this first and... 
07:10.220 --> 07:15.190 I'll go back to the holograms one-hundred page. 
07:15.190 --> 07:19.720 If we scroll down we see here that there are some exports settings 
07:19.720 --> 07:24.630 within Unity to enable application to run properly in 
07:24.630 --> 07:25.130 the HoloLens. 
07:26.260 --> 07:29.600 If you look closely everything looks pretty similar. We're gonna select 
07:29.600 --> 07:33.790 the windows store; the build setting is gonna be Windows Store we're gonna set the build type to 
07:33.790 --> 07:38.780 be 3D... But if you look right here there's actually an additional property that I did not 
07:38.780 --> 07:42.050 see next to the build settings called "Player Settings." So 
07:42.050 --> 07:46.720 if we go back to Unity and in the Build settings window, sure enough here is the 
07:46.720 --> 07:51.320 player settings. And the page specifies that in the "Other" 
07:51.320 --> 07:55.690 settings group, there's a "Rendering" section with the option for "Virtual Reality 
07:55.690 --> 07:59.330 Supported." This is a property I'm guessing... 
07:59.330 --> 08:03.410 Now I don't know this for sure, but it makes sense, that this property is 
08:03.410 --> 08:04.940 new and specific to 
08:04.940 --> 08:09.820 the Unity version is for HoloLens. I didn't verify this in the 
08:09.820 --> 08:14.540 previous versions, so if it is there, that's kinda neat that 
08:14.540 --> 08:16.240 it was kind of always there. 
08:16.240 --> 08:21.380 But for our purposes to run this in the HoloLens emulator we need to make sure that we 
08:21.380 --> 08:24.630 enable the virtual reality option and select 
08:24.630 --> 08:29.460 the virtual sdk for windows holographic. And actually now that I say that, it does make sense 
08:29.460 --> 08:34.020 this might have been in other versions for supporting other 
08:34.020 --> 08:38.420 virtual reality devices, the vr devices that are out, that are not 
08:38.420 --> 08:43.660 you know, augmented-mixed reality like a HoloLens. So it could be that just the sdk is present in this... Again, 
08:43.660 --> 08:47.460 this is not my area of expertise but, 
08:47.460 --> 08:51.520 it does kind of make sense. Ultimately what does really make the most sense obviously is 
08:51.520 --> 08:56.380 that the virtual reality option needs to be checked. Interestingly there was another 
08:56.380 --> 08:59.850 setting here under the project settings for quality 
08:59.850 --> 09:04.020 for Windows store to select the "fastest", which was interesting... this says here that 
09:04.020 --> 09:08.620 it's tuned for the fastest performance rather than the best quality. 
09:08.620 --> 09:13.690 Which I found curious, but I guess given the lower-powered nature of the device 
09:13.690 --> 09:18.370 as compared to say a PC that this isn't an unreasonable property... 
09:18.370 --> 09:23.310 So I'm going to go ahead and go into the project settings under quality, and select 
09:23.310 --> 09:28.160 the option here under Windows Store for the fastest. So there's a 
09:28.160 --> 09:30.390 drop-down here under the Windows Store logo and 
09:30.390 --> 09:34.350 we'll go ahead and select Fastest... So for Windows Store, that's what we want. 
09:34.350 --> 09:36.470 So we'll now save this 
09:36.470 --> 09:38.530 and verify again the setting that we have 
09:38.530 --> 09:43.980 selected the windows holographic, and we'll go ahead and rebuild this. 
09:43.980 --> 09:48.540 Now our Visual Studio project has been updated so 
09:48.540 --> 09:54.300 we'll go ahead and reload it and then rebuild it. 
09:54.300 --> 09:58.590 Now that that's done I'll make sure to select the TechRewards Challenge project 
09:58.590 --> 10:04.710 and launch that in the emulator. 
10:04.710 --> 10:11.510 So, now we see we get the full-screen logo and I think the.. let me kinda pull back a little bit. 
10:11.510 --> 10:15.110 I think the cubes are just out of view; I think I may have messed up the 
10:15.110 --> 10:19.980 camera position a little bit, but now you can see we get the 3D view that we expected. 
10:19.980 --> 10:25.290 So it looks like that's really what made all the difference here. But as you can 
10:25.290 --> 10:29.820 see is the same exact application 
10:29.820 --> 10:32.430 with the same exact 
10:32.430 --> 10:36.360 behavior of the two cubes, with player cube being 
10:37.430 --> 10:41.810 continuously bombarded by the enemy cube. So the exact same Unity 
10:41.810 --> 10:45.460 application, without modifying anything other than the 
10:45.460 --> 10:50.930 camera, the build settings and the player settings, 
10:50.930 --> 10:51.600 was able to 
10:51.600 --> 10:56.380 render the same holographic objects in the HoloLens 
10:56.380 --> 11:00.750 emulator, and I would also expect, the HoloLens device. 
11:00.750 --> 11:05.260 So when unity says it now supports the holographic platform they're not 
11:05.260 --> 11:08.950 kidding; it totally does! The same project, the same code 
11:08.950 --> 11:16.510 the same assets the same experience... well actually I would amend that by saying 
11:16.510 --> 11:19.270 an enhanced experience because... 
11:19.270 --> 11:24.260 This thing is right in front of you! So yeah, I hope that this 
11:24.260 --> 11:29.530 made sense to you; I hope it was useful and helpful in showing how you could take 
11:29.530 --> 11:31.260 your old Unity project and 
11:31.260 --> 11:36.070 repurpose it, adapt it to run in the HoloLense. Now I will add 
11:36.070 --> 11:39.600 that there's certainly a lot more to it than just 
11:39.600 --> 11:42.290 reopening the project and changing the settings. 
11:42.290 --> 11:47.610 There is entire an entirely different paradigm in the terms of 
11:47.610 --> 11:51.550 the user experience... And we'll talk more about that in the next 
11:51.550 --> 11:56.350 video because in the next video I plan to take 
11:56.350 --> 11:57.090 The HoloLens 
11:58.440 --> 12:02.980 I'm sorry the Unity... 
12:02.980 --> 12:07.090 So, from the unity website under the "Learn" section, there's a whole series of 
12:07.090 --> 12:11.040 tutorials and I want to see just what's involved in 
12:12.080 --> 12:17.600 adapting these to that they'll run in the HoloLens. So stay tuned to that... We'll start the 
12:17.600 --> 12:23.620 next video by looking at the "Roll a Ball" tutorial. This looks really exciting; 
12:23.620 --> 12:27.350 I am really hopeful that I'll be able to recreate this experience 
12:27.350 --> 12:32.160 of the floating objects for you to collect. We'll talk a little bit more about what's involved in that 
12:32.160 --> 12:36.870 and what I expect, the experience, and we'll run it through it together. So I hope you'll join 
12:36.870 --> 12:41.750 me. In the meantime, as always, I hope this was helpful, and I hope to hear your 
12:41.750 --> 12:48.270 feedback as you endeavour on your own HoloLens journey. Keep in touch, 
12:48.270 --> 12:54.850 reach me on twitter at @SelAromDotNet, or through, of course, Thanks watching, we'll see you next time.
The following two tabs change content below.


Senior Developer at iD Tech
Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.