Getting Started with the HoloPlay SDK
This is a tutorial on how to set up your first scene with the HoloPlay SDK. In it, we’ll be making a tower of cubes that we can knock over with our finger. This tutorial assumes that you have already installed Unity. If you have not, please see instructions on how to do so here. This tutorial also assumes that you have set up your HoloPlayer One and your computer settings correctly following this tutorial.
Step 1: Configure your Settings
The first thing we need to take care of is getting our computers set up correctly. You may remember that in the HoloPlayer One setup guide, we configured our computers in a particular way. It is important to know, though, that those settings are for running builds of Unity projects. In this tutorial, we’ll be using the Unity editor, and so our settings will be quite different.
The major difference will be that, when working in the editor, we want our displays to be extended, not mirrored. This will allow us to have Unity open on our 2D computer screen with the scene rendering on the HoloPlayer One.
Go to Displays in your System Preferences. Under the Displays, make sure that “Mirror Displays” is not toggled.
Also, make sure that your HoloPlayer One display is to the right of your computer screen in the settings.
Now we’re set up on our two screens and ready to do some development!
Open your display settings window. Make sure that the screen zoom, called “Change the size of text, apps, and other items” is set to 100%.
Now, make sure that, under “Multiple displays,” it is set to “Extend these displays.”
Now we’re set up on our two screens and ready to do some development!
Step 2: Setting up the HoloPlay SDK for Unity
Open Unity and you will be taken to the launcher window. Click “NEW” on the top right side of the window to start a new project.
Title the project whatever you feel is appropriate (I have gone with “HoloPlay Test,” you can go with something weird like “holographic pickles”). Make sure that 3D is selected and not 2D, and click “Create project” at the bottom right-hand side of the window.
With our new project ready, we want bring in the HoloPlay SDK asset package. Download the HoloPlay SDK Unity package from our forum. Once it has finished downloading, find it in your downloads and double click the Go back to the folder where the HoloPlay SDK, and double click on the the file called “HoloPlaySDK-0.362” (Kyle is forever improving the SDK so it’s likely that you will be downloading a much newer version by the time you get to this).
This should jump you back to Unity, now with a window open ready to import the HoloPlay SDK package. Click the “Import” button on that window to load the package into your Unity project.
You should see the HoloPlaySDK-0.362 folder appear in your project tab. Open the folder, and find the “HoloPlay Capture” prefab. Put it in your scene by clicking and dragging the object into your “Hierarchy” tab. You should see a green volume appear in the middle of your Unity scene.
The HoloPlay Capture game object determines what draws to your HoloPlayer One. To make it draw, we first have to move our game window to our HoloPlayer One display rather than our computer screen. To do so, just press “Control-E” (“Command-E” on Macs) on your keyboard. Your HoloPlayer One should go from drawing your desktop background to just being black. That’s a good thing! But it’s also pretty boring. Let’s have it draw something. We could put anything within the green bounding box of our HoloPlay Capture object and have it render into your HoloPlayer One, but for now let’s just add a cube. Select the “GameObject” tab at the top of the screen, select “3D Object,” and select “Cube.”
As long as your cube is within the range of the HoloPlay Capture (inside the green bounding box) it will render on your HoloPlayer One. It should, by default, already be drawing in 3D. If it is not, either press the play button to run the scene, or select the “HoloPlay Capture” game object in your hierarchy. You should see that object’s components show up in your “Inspector” tab, with the second component from the top being “Holo Play (Script).” Make sure the “Render in editor” option on that component is set to “on,” and the cube should now be 3D in your HoloPlayer One!
Step 3: Setting up RealSense interaction
With the HoloPlay Capture set up, we can now get interaction running. Woohoo!
The HoloPlay Capture game object only allows us to draw to the HoloPlayer One. Another prefab in the package, called the “Realsense Manager,” controls interaction. Bring it into our scene as well by clicking the prefab and dragging it into your Hierarchy.
The Realsense Manager has a child game object, your “Realsense Cursor.” This object will follow your finger as you move it through the interaction area of the HoloPlayer One. Run your scene now and move your finger through the interaction area of your HoloPlayer One, and this should already be working!
The cursor moves in one of two ways, either using Unity physics or not, which is set on the “Calibrated Pointer (Script)” component via the “Physics Based Movement” toggle.
By default, this is set to false. For this demonstration, we’ll want to use Unity physics, so let’s change that to true by clicking the toggle. For this to work, though, you must add a Rigidbody component to the game object and you must add a collider of some kind (I recommend a sphere collider) to have proper physics interactions. Let’s add both, as we’ll want to use Unity physics in this demonstration.
Note that I have changed two settings on the Rigidbody: toggling off “Use Gravity” and toggling on “Is Kinematic.”
Now that our cursor is set to move with physics, press play to run your scene. Point your index finger into the interaction area of the HoloPlayer One, you should see the cursor follow your finger!
Now, let’s do something a bit more interesting with it by putting in some blocks to push around. First, add a plane to the scene to serve as our floor. To do so, click the “GameObject” tab, then select “3D Object” and click on “Plane.”
With the plane in your scene, make sure its X and Z coordinates are both set to 0 on the transform, and move the Y coordinate down to -3.
Now that our floor is in place, let’s add some cubes and give them physics! Create two more cubes by clicking the “GameObject” tab, then select “3D Object” and click “Cube.” Select each cube in the hierarchy, and add a Rigidbody component to each.
The cubes may all be in the same position, which will give us some WACKY physics interactions. Instead, let’s just make a cube tower! Select the first cube (“Cube” in your hierarchy) and move its transform position to (0,0,0). Select the second cube (“Cube (1)”) and move its transform position to (0,-1,0). Then select the third cube (“Cube (2)”) and move its transform position to (0,-2,0). You should see your cubes form a tower floating just above the plane in your HoloPlayer One.
Press play to run your scene, and touch the tower with your finger to knock over the blocks!
Congratulations! You’ve now made your first project with the HoloPlay SDK! To access the source for this project, and to see other projects made with the HoloPlay SDK, check out our forum for all the latest releases!