Creating default picture

For starters, let's work with just one picture in the scene. We'll name it DefaultPicture. DefaultPicture will be an object Hierarchy. Later, we'll make it a prefab that gets instantiated when the user adds new pictures to the scene.

  1. In Hierarchy, click Create Empty and name it DefaultPicture.
  2. As a child of DefaultPicture, create another Empty and name it FramedImage.
  3. From Project Assets/PhotoFrames/Prefabs, drag the Frame 1 prefab to be a child of FramedImage.

If you are not using our frame prefabs, you can make a quick one by creating a cube and creating an appropriately colored material for it, as follows:

    1. With FramedImage selected, right-click 3D Object | Cube, and name it Frame 1
    2. Scale the frame to (1.2, 1.2, 0.02) Position (0, 0, 0.02).
    3. In the Project Assets/App/Materials folder, Create | Material and name it Frame 1.
    4. Give it an interesting color.
    5. Drag the Frame 1 material onto the Frame 1 object.
  1. Add an image. We'll use a quad primitive object with a new Image material to hold the .jpg texture:
    1. In your Project Assets/App/Materials folder, Create | Material and name it Image.
    2. From the Assets/Images/ folder, drag the mountains texture onto the Albedo texture chip (left side of the Albedo property).
    3. In Hierarchy, with FramedImage selected, right-click 3D Object | Quad and name it Image.
  2. Drag the Image material from the project's Assets onto the quad.

The image appears in the frame, but the frame and image are square. We know that this image is 1280 x 774, or about 1:0.6 aspect ratio.

  1. Let's scale the FramedImage accordingly (we'll automate this with a script later on) by setting the FramedImage Transform Scale Y to 0.6.

If you look at the Game window right now, it's empty. That is because both the Main Camera and the DefaultPicture are at the origin, so the camera cannot see it.

  1. Let's move the picture out in front of the camera and scale it down a bit as shown ahead (this isn't the Louvre; a one-meter-wide picture is too big for my house!):
    1. Set the DefaultPicture Transform Position to 0, 0, 1.6.
    2. Set its Scale to 0.3, 0.3, 0.3.
  2. Save the scene.
  3. Press Play in the Unity Editor to take a look.

As explained in Chapter 3, Building Your App, you should have your HoloLens set up for development. To use the device from Unity Play mode, do the following:

  1. Run the Holographic Remoting player app on the device (find it in the bloom gesture system menu).
  2. Then, in Unity, from the main menu, open the Window | Holographic Emulation.
  3. Choose Emulation Mode: Remote to Device, and enter the Remote Machine IP address of your HoloLens device (as displayed on its screen).
  4. Press Connect.

Now you are set up. When you press Play in the editor, it will run on your device.

You will see the framed image floating about five feet in front of you, as shown here:

You will also see the cursor, tracked with your head movement. This is the CursorWithFeedback cursor controlled using the InputManager that we added to the scene. Let's take a closer look at Input Manager and cursors.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset