Unity Virtual Reality Projects
上QQ阅读APP看书,第一时间看更新

Adding a sphere and some material

Next, let's add a sphere. Select GameObject | 3D Object | Sphere from the menu.

Like the cube, the sphere has a radius of 1.0, with its origin at the center. (If necessary, select Reset from the Inspector panel Transform component's gear icon). It's hard to see the sphere as it is embedded in the cube. We need to move the sphere's position.

This time, let's use the Scene panel's Gizmos component to move the object. In the Scene view, you can select graphical controls, or Gizmos, to manipulate the objects transforms, as illustrated in the following screenshot from the Unity documentation (http://docs.unity3d.com/Manual/PositioningGameObjects.html):

In the Scene panel, with the sphere selected, make sure that the Translate tool is active (second icon on the top-left icon toolbar) and use the arrows of the x, y, and axes to position it. I left mine at Position (1.6, 0.75, -1.75).

A Gizmo is a graphical control that lets you manipulate the parameters of an object or a view. Gizmos have grab points or handles that you can click and drag with the mouse.

Before we go much further, let's save our work as follows:

  1. From the main menu bar, select File | Save Scene As... and name it Diorama.
  2. Also, navigate to File | Save Project for good measure. Note that in the Project panel, the new scene object was saved in the top-level Assets folder.

Let's add some color to the scene by making a couple of colored materials and applying them to our objects. Follow these steps:

  1. In the Project panel, select the top-level Assets folder and select Create | Folder. Rename the folder to Materials.
  2. With the Materials folder selected, select Create | Material and rename it to Red Material.
  3. In the Inspector panel, click the white rectangle to the right of Albedo, which opens the Color panel. Choose a nice juicy red.
  4. Repeat the preceding steps to make a Blue Material too.
  5. Select Sphere from the Hierarchy (or Scene) panel.
  6. Drag the Red Material from the Project panel into the Inspector panel for the sphere. The sphere should now look red.
  7. Select Cube from the Scene (or Hierarchy) panel.
  8. This time, drag the Blue Material from the Project panel into the scene and drop it onto the cube. It should now look blue.

Save your scene and save the project. Here's what my scene looks like now (yours might be a little different, but that's OK):

Note that we're using the folders in the Project panel /Assets/ directory to organize our stuff.